From accdaeec436156fb4876c31e99530e2029e33c0f Mon Sep 17 00:00:00 2001 From: Nia Bickford Date: Tue, 25 Nov 2025 00:21:21 -0800 Subject: [PATCH] Add fix for https://github.com/nothings/stb/issues/1860 by checking multiplication before allocating. --- stb_image.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stb_image.h b/stb_image.h index 9eedabedc4..b7c11ba023 100644 --- a/stb_image.h +++ b/stb_image.h @@ -1817,7 +1817,7 @@ static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int r if (req_comp == img_n) return data; STBI_ASSERT(req_comp >= 1 && req_comp <= 4); - good = (stbi__uint16 *) stbi__malloc(req_comp * x * y * 2); + good = (stbi__uint16 *) stbi__malloc_mad4(req_comp, x, y, 2, 0); if (good == NULL) { STBI_FREE(data); return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory");