From 445473bdb5f7813487b6f8f808d3ae84801937da Mon Sep 17 00:00:00 2001 From: Sean Barrett Date: Mon, 29 Jan 2018 08:03:56 -0800 Subject: [PATCH] stb_image_write: handle malloc failure in zlib --- stb_image_write.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stb_image_write.h b/stb_image_write.h index d318e0e..eaf5093 100644 --- a/stb_image_write.h +++ b/stb_image_write.h @@ -817,6 +817,8 @@ unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_l int i,j, bitcount=0; unsigned char *out = NULL; unsigned char ***hash_table = (unsigned char***) STBIW_MALLOC(stbiw__ZHASH * sizeof(char**)); + if (hash_table == NULL) + return NULL; if (quality < 5) quality = 5; stbiw__sbpush(out, 0x78); // DEFLATE 32K window