From f4ca3f6783bb3d78a9f158efe4874d426b75ae72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Novomesk=C3=BD?= Date: Tue, 13 Dec 2022 11:11:38 +0100 Subject: [PATCH] heif: fix error handling --- src/imageformats/heif.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/imageformats/heif.cpp b/src/imageformats/heif.cpp index b10b142..3365d92 100644 --- a/src/imageformats/heif.cpp +++ b/src/imageformats/heif.cpp @@ -289,13 +289,14 @@ bool HEIFHandler::write_helper(const QImage &image) heif_encoder_release(encoder); heif_image_release(h_image); - heif_context_free(context); if (err.code) { qWarning() << "Writing HEIF image failed:" << err.message; + heif_context_free(context); return false; } + heif_context_free(context); return true; } @@ -433,8 +434,8 @@ bool HEIFHandler::ensureDecoder() struct heif_error err = heif_context_read_from_memory(ctx, static_cast(buffer.constData()), buffer.size(), nullptr); if (err.code) { - heif_context_free(ctx); qWarning() << "heif_context_read_from_memory error:" << err.message; + heif_context_free(ctx); m_parseState = ParseHeicError; return false; } @@ -442,8 +443,8 @@ bool HEIFHandler::ensureDecoder() struct heif_image_handle *handle = nullptr; err = heif_context_get_primary_image_handle(ctx, &handle); if (err.code) { - heif_context_free(ctx); qWarning() << "heif_context_get_primary_image_handle error:" << err.message; + heif_context_free(ctx); m_parseState = ParseHeicError; return false; } @@ -496,9 +497,9 @@ bool HEIFHandler::ensureDecoder() } if (err.code) { + qWarning() << "heif_decode_image error:" << err.message; heif_image_handle_release(handle); heif_context_free(ctx); - qWarning() << "heif_decode_image error:" << err.message; m_parseState = ParseHeicError; return false; }