From f07727a28a5321c4a2e57215334a3a38ed773a33 Mon Sep 17 00:00:00 2001 From: Thomas Ruf Date: Wed, 28 Dec 2016 14:16:45 +0100 Subject: [PATCH] stb_image.h: large structures on the stack more of "allocate large structures on the stack", this time in the forgotten stbi__jpeg_test -> avoids the infamous _chkstk() when working with CRT --- stb_image.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/stb_image.h b/stb_image.h index 345e406..2425c42 100644 --- a/stb_image.h +++ b/stb_image.h @@ -3703,11 +3703,12 @@ static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int re static int stbi__jpeg_test(stbi__context *s) { int r; - stbi__jpeg j; - j.s = s; - stbi__setup_jpeg(&j); - r = stbi__decode_jpeg_header(&j, STBI__SCAN_type); + stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg)); + j->s = s; + stbi__setup_jpeg(j); + r = stbi__decode_jpeg_header(j, STBI__SCAN_type); stbi__rewind(s); + STBI_FREE(j); return r; }