Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions stb_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -6956,7 +6956,10 @@ static void *stbi__load_gif_main_outofmem(stbi__gif *g, stbi_uc *out, int **dela
STBI_FREE(g->background);

if (out) STBI_FREE(out);
if (delays && *delays) STBI_FREE(*delays);
if (delays && *delays) {
STBI_FREE(*delays);
*delays = NULL;
}
return stbi__errpuc("outofmem", "Out of memory");
}

Expand Down Expand Up @@ -6991,19 +6994,15 @@ static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y,
stride = g.w * g.h * 4;

if (out) {
void *tmp = (stbi_uc*) STBI_REALLOC_SIZED( out, out_size, layers * stride );
if (!tmp)
out = (stbi_uc*) STBI_REALLOC_SIZED( out, out_size, layers * stride );
if (!out)
return stbi__load_gif_main_outofmem(&g, out, delays);
else {
out = (stbi_uc*) tmp;
out_size = layers * stride;
}
out_size = layers * stride;

if (delays) {
int *new_delays = (int*) STBI_REALLOC_SIZED( *delays, delays_size, sizeof(int) * layers );
if (!new_delays)
*delays = (int*) STBI_REALLOC_SIZED( *delays, delays_size, sizeof(int) * layers );
if (!*delays)
return stbi__load_gif_main_outofmem(&g, out, delays);
*delays = new_delays;
delays_size = layers * sizeof(int);
}
} else {
Expand Down
Loading