Skip to content

Commit

Permalink
Fixed crash loading webp files when out of memory
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jan 8, 2025
1 parent 9f115a1 commit f1ed915
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/IMG_webp.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ IMG_Animation *IMG_LoadWEBPAnimation_IO(SDL_IOStream *src)
anim->count = lib.WebPDemuxGetI(demuxer, WEBP_FF_FRAME_COUNT);
anim->frames = (SDL_Surface **)SDL_calloc(anim->count, sizeof(*anim->frames));
anim->delays = (int *)SDL_calloc(anim->count, sizeof(*anim->delays));
if (!anim->frames || !anim->delays) {
goto error;
}

canvas = SDL_CreateSurface(anim->w, anim->h, features.has_alpha ? SDL_PIXELFORMAT_RGBA32 : SDL_PIXELFORMAT_RGBX32);
if (!canvas) {
Expand Down

0 comments on commit f1ed915

Please sign in to comment.