From a15dded5ca5ebb4ca18e553349f2b3f9594484d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Loba=C4=8Devski?= Date: Thu, 19 Oct 2023 16:16:34 +0200 Subject: [PATCH] Fix double-free in stbi__load_gif_main_outofmem Fixes #1544 --- stb_image.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stb_image.h b/stb_image.h index 5e807a0a6e..0614650697 100644 --- a/stb_image.h +++ b/stb_image.h @@ -6990,6 +6990,10 @@ static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, stride = g.w * g.h * 4; if (out) { + if (stride == 0) { + void *ret = stbi__load_gif_main_outofmem(&g, out, delays); + return ret; + } void *tmp = (stbi_uc*) STBI_REALLOC_SIZED( out, out_size, layers * stride ); if (!tmp) return stbi__load_gif_main_outofmem(&g, out, delays);