Skip to content

Malloc return not checked in stbi_write_hdr_core #1645

@catenacyber

Description

@catenacyber

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 github/codeql#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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions