diff --git a/modules/imgcodecs/src/grfmt_avif.cpp b/modules/imgcodecs/src/grfmt_avif.cpp index 6b5c2cda8b..4b39ada60a 100644 --- a/modules/imgcodecs/src/grfmt_avif.cpp +++ b/modules/imgcodecs/src/grfmt_avif.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include "opencv2/imgproc.hpp" @@ -159,16 +160,16 @@ size_t AvifDecoder::signatureLength() const { return kAvifSignatureSize; } } bool AvifDecoder::checkSignature(const String &signature) const { - avifDecoder *decoder = avifDecoderCreate(); + std::unique_ptr decoder( + avifDecoderCreate(), avifDecoderDestroy); if (!decoder) return false; OPENCV_AVIF_CHECK_STATUS( avifDecoderSetIOMemory( - decoder, reinterpret_cast(signature.c_str()), + decoder.get(), reinterpret_cast(signature.c_str()), signature.size()), decoder); decoder->io->sizeHint = 1e9; - const avifResult status = avifDecoderParse(decoder); - avifDecoderDestroy(decoder); + const avifResult status = avifDecoderParse(decoder.get()); return (status == AVIF_RESULT_OK || status == AVIF_RESULT_TRUNCATED_DATA); }