Browse Source

stb_image_write: handle malloc failure in zlib

Sean Barrett 7 years ago
parent
commit
445473bdb5
1 changed files with 2 additions and 0 deletions
  1. 2 0
      stb_image_write.h

+ 2 - 0
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