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); \