Skip to content

Commit

Permalink
check heif_image_get_primary_width() for error
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Oct 22, 2024
1 parent fd7dc03 commit 480b371
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion examples/heif_enc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ heif_image_handle* encode_tiled(heif_context* ctx, heif_encoder* encoder, heif_e
std::cout << "encoding tiled image, tile size: " << tiling.tile_width << "x" << tiling.tile_height
<< " image size: " << tiling.image_width << "x" << tiling.image_height << "\n";

uint32_t tile_width = 0, tile_height = 0;
int tile_width = 0, tile_height = 0;

for (uint32_t ty = 0; ty < tile_generator.nRows(); ty++)
for (uint32_t tx = 0; tx < tile_generator.nColumns(); tx++) {
Expand All @@ -808,6 +808,11 @@ heif_image_handle* encode_tiled(heif_context* ctx, heif_encoder* encoder, heif_e
if (tile_width == 0) {
tile_width = heif_image_get_primary_width(input_image.image.get());
tile_height = heif_image_get_primary_height(input_image.image.get());

if (tile_width <= 0 || tile_height <= 0) {
std::cerr << "Could not read input image size correctly\n";
return nullptr;
}
}

heif_error error;
Expand Down

0 comments on commit 480b371

Please sign in to comment.