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:
parent
b08a198f00
commit
8eec337fee
|
|
@ -649,7 +649,7 @@ _ostree_delta_get_endianness (GVariant *superblock,
|
||||||
* deltas, period. Past the gigabyte scale you really want
|
* deltas, period. Past the gigabyte scale you really want
|
||||||
* bittorrent or something.
|
* bittorrent or something.
|
||||||
*/
|
*/
|
||||||
if ((total_size / total_objects) > G_MAXUINT32)
|
if (total_objects > 0 && (total_size / total_objects) > G_MAXUINT32)
|
||||||
{
|
{
|
||||||
is_byteswapped = TRUE;
|
is_byteswapped = TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue