:: commit 9ee0e8d4e4dc3e1f45e7f9d1ee8d0c6e78ef9ced

Mintsuki <mintsuki@protonmail.com> — 2025-04-12 19:04

parents: 08ed65f63e

stb_image: Fix potential null deref in stbi_realloc()

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); \
tab: 248 wrap: offon