Skip to content

Commit

Permalink
Add stb_image regression test for attempted PoC in nothings#1454 (com…
Browse files Browse the repository at this point in the history
  • Loading branch information
NBickford-NV committed Jan 10, 2025
1 parent 5addd83 commit 2b7b082
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ if(NOT STB_SANITIZERS)
endif()
endif()

#-------------------------------------------------------------------------------
# stb_image regression test cases
add_executable(stb_image_test_issues
image/image_test_issues.c
image/1454_gif.h
)
target_compile_options(stb_image_test_issues PRIVATE ${STB_SANITIZERS})
if(UNIX)
target_link_options(stb_image_test_issues PRIVATE ${STB_SANITIZERS})
endif()

#-------------------------------------------------------------------------------
# Vorbis test cases
add_executable(stb_vorbis_test_issues
Expand Down
33 changes: 33 additions & 0 deletions tests/image/1454_gif.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* https://github.com/nothings/stb/pull/1454#issuecomment-2581308033 */

#include "../../stb_image.h"

#include <stdlib.h>

int test_1454_gif()
{
const stbi_uc data[] = { 'G', 'I', 'F', '8', '9', 'a', // Magic number
1, 0, 1, 0, // Width and height
0, 0, 0}; // flags, bgindex, ratio
int size = (int)sizeof(data);

int *delays = NULL;
int x, y, z, comp;
stbi_uc* image = stbi_load_gif_from_memory(
(const stbi_uc*)data, size,
&delays,
&x, &y, &z,
&comp, 3);

if (image)
{
stbi_image_free(image);
}

if (delays)
{
stbi_image_free(delays);
}

return EXIT_SUCCESS;
}
8 changes: 8 additions & 0 deletions tests/image/image_test_issues.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "1454_gif.h"

#define STB_IMAGE_IMPLEMENTATION
#include "../../stb_image.h"

int main() {
test_1454_gif();
}

0 comments on commit 2b7b082

Please sign in to comment.