lib/deltas: Squash Coverity warning for div-by-zero in delta show

If a delta happens to have zero objects, we could end up doing
a divide-by-zero when inferring endianness.  In practice,
a zero-object delta isn't possible to generate I think, but
let's make sure the code is defensive all the same.

Spotted by Coverity.

Coverity CID: 1452208

Closes: #1041
Approved by: pwithnall
This commit is contained in:
Colin Walters 2017-07-31 12:27:31 -04:00 committed by Atomic Bot
parent b08a198f00
commit 8eec337fee

View File

@ -649,7 +649,7 @@ _ostree_delta_get_endianness (GVariant *superblock,
* deltas, period. Past the gigabyte scale you really want
* bittorrent or something.
*/
if ((total_size / total_objects) > G_MAXUINT32)
if (total_objects > 0 && (total_size / total_objects) > G_MAXUINT32)
{
is_byteswapped = TRUE;
}