From 480b37143e9e98c7579d4e7344b3196cff580976 Mon Sep 17 00:00:00 2001 From: Dirk Farin Date: Tue, 22 Oct 2024 19:41:49 +0200 Subject: [PATCH] check heif_image_get_primary_width() for error --- examples/heif_enc.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/heif_enc.cc b/examples/heif_enc.cc index 7bcdaee487..a5678755db 100644 --- a/examples/heif_enc.cc +++ b/examples/heif_enc.cc @@ -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++) { @@ -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;