Skip to content

Commit

Permalink
prevent divide-by-zero without generating error (#1349)
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Oct 27, 2024
1 parent 33ac76d commit 6110752
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions libheif/image-items/image_item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1050,17 +1050,21 @@ Error ImageItem::process_image_transformations_on_tiling(heif_image_tiling& tili

const std::vector<std::shared_ptr<Box>>& properties = *propertiesResult;

// Prevent divide by zero.

uint32_t left_excess = 0;
uint32_t top_excess = 0;
uint32_t right_excess = 0;
uint32_t bottom_excess = 0;
uint32_t right_excess;
uint32_t bottom_excess;

// Prevent divide by zero.

if (tiling.tile_width != 0 && tiling.tile_height != 0) {
right_excess = tiling.image_width % tiling.tile_width;
bottom_excess = tiling.image_height % tiling.tile_height;
}
else {
right_excess = 0;
bottom_excess = 0;
}


for (const auto& property : properties) {
Expand Down

0 comments on commit 6110752

Please sign in to comment.