Skip to content

Commit 08ed65f

Browse files
committed
stb_image: Fix calculation of old size in stbi_realloc()
1 parent 15b57fb commit 08ed65f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

common/stb_image.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
+ void *STBI_REALLOC_buf = (x); \
3636
+ size_t STBI_REALLOC_alloc_size = (y); \
3737
+ void *STBI_REALLOC_new_buf = STBI_MALLOC(STBI_REALLOC_alloc_size); \
38-
+ size_t STBI_REALLOC_old_size = *(size_t *)((void *)STBI_REALLOC_buf - 16); \
38+
+ size_t STBI_REALLOC_old_size = (*(size_t *)((void *)STBI_REALLOC_buf - 16)) - 16; \
3939
+ if (STBI_REALLOC_buf != NULL) { \
4040
+ memcpy(STBI_REALLOC_new_buf, STBI_REALLOC_buf, \
4141
+ MIN(STBI_REALLOC_alloc_size, STBI_REALLOC_old_size)); \

0 commit comments

Comments
 (0)