add malloc failure test for cgif_rgb API#95
Conversation
There was a problem hiding this comment.
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.cthat implements malloc/realloc failure injection by wrapping these functions and including source files directly - Updated
tests/meson.buildto 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.
4c9888f to
f468b82
Compare
There was a problem hiding this comment.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
e0a7173 to
4d2ce4b
Compare
MCLoebl
left a comment
There was a problem hiding this comment.
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.
Iteratively fail each malloc call in the cgif_rgb code path (newgif + addframe + close) to verify all allocation failures are handled correctly without crashes.