Skip to content

fix(cgif_rgb): add NULL checks after allocations#97

Closed
uwezkhan wants to merge 1 commit into
dloebl:mainfrom
uwezkhan:fix/add-null-checks-cgif-rgb
Closed

fix(cgif_rgb): add NULL checks after allocations#97
uwezkhan wants to merge 1 commit into
dloebl:mainfrom
uwezkhan:fix/add-null-checks-cgif-rgb

Conversation

@uwezkhan

Copy link
Copy Markdown
Contributor

fix(cgif_rgb): add NULL checks after allocations

Add missing NULL pointer checks after malloc/realloc calls to prevent
crashes on memory allocation failures. This fixes critical security
vulnerabilities where NULL pointers were dereferenced without checking.

Changes:

  • init_col_hash_table: Check malloc return value
  • resize_col_hash_table: Check realloc and malloc return values
  • hash_to_dense: Check malloc return value
  • new_tree_node: Check malloc return value
  • quantize_and_dither: Check malloc, cleanup on failure
  • cgif_rgb_newgif: Check malloc return value
  • cgif_rgb_addframe: Check malloc twice, cleanup on failure

Impact:

  • Prevents guaranteed crashes in low-memory conditions
  • Properly propagates CGIF_EALLOC error code
  • Adds cleanup for partially allocated memory
  • No changes to success path or API

Total: 7 functions fixed, 31 lines added, 0 lines removed

@uwezkhan

Copy link
Copy Markdown
Contributor Author

Hey i have added a PR please check

@dloebl

dloebl commented Feb 22, 2026

Copy link
Copy Markdown
Owner

Hey @uwezkhan,
please refer to the contributing guidelines before opening any new pull requests or issues. Thanks.

@dloebl dloebl closed this Feb 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants