From 8d81f48e28bc6915fe8e16817ef807460053fe11 Mon Sep 17 00:00:00 2001 From: Dirk Farin Date: Tue, 15 Oct 2024 12:07:58 +0200 Subject: [PATCH] heif-dec: make sure that heif_decoding_options is freed --- examples/heif_dec.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/heif_dec.cc b/examples/heif_dec.cc index 7a09ad0aec..2b9dc3cb86 100644 --- a/examples/heif_dec.cc +++ b/examples/heif_dec.cc @@ -830,8 +830,8 @@ int main(int argc, char** argv) return 1; } - struct heif_decoding_options* decode_options = heif_decoding_options_alloc(); - encoder->UpdateDecodingOptions(handle, decode_options); + std::unique_ptr decode_options(heif_decoding_options_alloc(), heif_decoding_options_free); + encoder->UpdateDecodingOptions(handle, decode_options.get()); decode_options->strict_decoding = strict_decoding; decode_options->decoder_id = decoder_id; @@ -848,13 +848,12 @@ int main(int argc, char** argv) int ret; if (option_output_tiles) { - ret = decode_image_tiles(handle, numbered_output_filename_stem, output_filename_suffix, decode_options, encoder); + ret = decode_image_tiles(handle, numbered_output_filename_stem, output_filename_suffix, decode_options.get(), encoder); } else { - ret = decode_single_image(handle, numbered_output_filename_stem, output_filename_suffix, decode_options, encoder); + ret = decode_single_image(handle, numbered_output_filename_stem, output_filename_suffix, decode_options.get(), encoder); } if (ret) { - heif_decoding_options_free(decode_options); heif_image_handle_release(handle); return ret; }