Skip to content

add malloc failure test for cgif_rgb API#95

Merged
dloebl merged 7 commits into
mainfrom
ealloc_rgb_test
Mar 15, 2026
Merged

add malloc failure test for cgif_rgb API#95
dloebl merged 7 commits into
mainfrom
ealloc_rgb_test

Conversation

@dloebl

@dloebl dloebl commented Feb 11, 2026

Copy link
Copy Markdown
Owner

Iteratively fail each malloc call in the cgif_rgb code path (newgif + addframe + close) to verify all allocation failures are handled correctly without crashes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a malloc failure test for the cgif_rgb API to verify that all memory allocation failures are handled correctly without crashes. The test iteratively fails each malloc/realloc call in the code path (newgif + addframe + close) by injecting failures at each allocation point.

Changes:

  • Added a new test file tests/ealloc_rgb.c that implements malloc/realloc failure injection by wrapping these functions and including source files directly
  • Updated tests/meson.build to compile and run the new test

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/ealloc_rgb.c New malloc failure test that wraps malloc/realloc to inject failures at each allocation point and verifies the cgif_rgb API handles them gracefully
tests/meson.build Adds build configuration for the new malloc failure test, compiling the source directly without linking to libcgif

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/ealloc_rgb.c

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cgif_rgb.c Outdated

@MCLoebl MCLoebl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the test ealloc_rgb.c, the function initImageData looks somewhat odd. Looking at l. 487 in cgif_rgb.c, the initial hashtable size is 262147, not 524309. Should l.75-80 be adapted such that hash collisions and table resize is done several times? The meaning of 31 as MAX_COLLISIONS+1 should be explicit. The image size WIDTH * HEIGHT is 17*18 =288 > 31.

@dloebl dloebl merged commit 436d5a4 into main Mar 15, 2026
15 checks passed
@dloebl dloebl deleted the ealloc_rgb_test branch March 15, 2026 20:47
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.

3 participants