Skip to content

Commit f1ed915

Browse files
committed
Fixed crash loading webp files when out of memory
1 parent 9f115a1 commit f1ed915

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/IMG_webp.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,9 @@ IMG_Animation *IMG_LoadWEBPAnimation_IO(SDL_IOStream *src)
329329
anim->count = lib.WebPDemuxGetI(demuxer, WEBP_FF_FRAME_COUNT);
330330
anim->frames = (SDL_Surface **)SDL_calloc(anim->count, sizeof(*anim->frames));
331331
anim->delays = (int *)SDL_calloc(anim->count, sizeof(*anim->delays));
332+
if (!anim->frames || !anim->delays) {
333+
goto error;
334+
}
332335

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

0 commit comments

Comments
 (0)