**Describe the bug** https://github.com/nothings/stb/blob/master/stb_image_write.h#L767 does not check the malloc return value, when it can be NULL and later dereferenced **To Reproduce** Found with CodeQL query https://github.com/github/codeql/pull/16524 (only finding in this project) **Expected behavior** Check the return value, and return early as in the other cases like https://github.com/nothings/stb/blob/master/stb_image_write.h#L909 Simple patch like would be to ass ``` if (scratch == NULL) return 0; ```