[frameworks/kimageformats/Frameworks/6.28] src/imageformats: HEIF: keep reader callback table alive

Nicolas Fella <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit ac374da215eb30d67355be00c89a73c06fea8ae8 by Nicolas Fella, on behalf of Kyle Alexander Buan.
Committed on 20/07/2026 at 18:52.
Pushed by nicolasfella into branch 'Frameworks/6.28'.

HEIF: keep reader callback table alive

libheif retains the heif_reader pointer after
heif_context_read_from_reader returns. The callback table was scoped
to the non-sequential branch and could be destroyed before
tiled image decoding used it from worker threads.

Give the callback table static storage duration.

BUG: 523105
(cherry picked from commit ad0fb9dde4ffb1977a3ea800d90a26665de687b8)

M  +2    -1    src/imageformats/heif.cpp

https://invent.kde.org/frameworks/kimageformats/-/commit/ac374da215eb30d67355be00c89a73c06fea8ae8

diff --git a/src/imageformats/heif.cpp b/src/imageformats/heif.cpp
index 7b96aa96..73bd6822 100644
--- a/src/imageformats/heif.cpp
+++ b/src/imageformats/heif.cpp
@@ -711,7 +711,8 @@ bool HEIFHandler::ensureDecoder()
         buffer = deviceRead(dev, kMaxQVectorSize);
         err = heif_context_read_from_memory(ctx, static_cast<const void *>(buffer.constData()), buffer.size(), nullptr);
     } else {
-        heif_reader reader = create_heif_reader_for_qiodevice();
+        // Must not be destroyed until decoding ends
+        static const heif_reader reader = create_heif_reader_for_qiodevice();
         err = heif_context_read_from_reader(ctx, &reader, dev, nullptr);
     }
     if (err.code) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.