From 9ee0e8d4e4dc3e1f45e7f9d1ee8d0c6e78ef9ced Mon Sep 17 00:00:00 2001 From: Mintsuki Date: Sat, 12 Apr 2025 21:04:10 +0200 Subject: [PATCH] stb_image: Fix potential null deref in stbi_realloc() --- common/stb_image.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/stb_image.patch b/common/stb_image.patch index 33171d06..093eca2d 100644 --- a/common/stb_image.patch +++ b/common/stb_image.patch @@ -35,8 +35,8 @@ + void *STBI_REALLOC_buf = (x); \ + size_t STBI_REALLOC_alloc_size = (y); \ + void *STBI_REALLOC_new_buf = STBI_MALLOC(STBI_REALLOC_alloc_size); \ -+ size_t STBI_REALLOC_old_size = (*(size_t *)((void *)STBI_REALLOC_buf - 16)) - 16; \ + if (STBI_REALLOC_buf != NULL) { \ ++ size_t STBI_REALLOC_old_size = (*(size_t *)((void *)STBI_REALLOC_buf - 16)) - 16; \ + memcpy(STBI_REALLOC_new_buf, STBI_REALLOC_buf, \ + MIN(STBI_REALLOC_alloc_size, STBI_REALLOC_old_size)); \ + STBI_FREE(STBI_REALLOC_buf); \