File giflib-CVE-2026-23868.patch of Package giflib.43162

From c8195c980e2479fa2bac071dfe4d5dff4811d6af Mon Sep 17 00:00:00 2001
From: "Eric S. Raymond" <esr@thyrsus.com>
Date: Wed, 4 Mar 2026 18:49:49 -0500
Subject: [PATCH] Avoid potentuial double-free on weird images.

---
 lib/gifalloc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/gifalloc.c b/lib/gifalloc.c
index 5726e76..2ea96c4 100644
--- a/lib/gifalloc.c
+++ b/lib/gifalloc.c
@@ -332,6 +332,14 @@ GifMakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom)
              * problems.
              */
 
+            /* Null out aliased pointers before any allocations
+             * so that FreeLastSavedImage won't free CopyFrom's
+             * data if an allocation fails partway through. */
+            sp->ImageDesc.ColorMap = NULL;
+            sp->RasterBits = NULL;
+            sp->ExtensionBlocks = NULL;
+            sp->ExtensionBlockCount = 0;
+
             /* first, the local color map */
             if (sp->ImageDesc.ColorMap != NULL) {
                 sp->ImageDesc.ColorMap = GifMakeMapObject(
-- 
2.53.0

openSUSE Build Service is sponsored by