File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -576,6 +576,8 @@ static twin_animation_t *_twin_animation_from_gif_file(const char *path)
576576 uint8_t * color , * frame ;
577577 frame = malloc (gif -> width * gif -> height * 3 );
578578 if (!frame ) {
579+ free (anim -> frame_delays );
580+ free (anim -> frames );
579581 free (anim );
580582 gif_close (gif );
581583 return NULL ;
@@ -584,6 +586,12 @@ static twin_animation_t *_twin_animation_from_gif_file(const char *path)
584586 anim -> frames [i ] =
585587 twin_pixmap_create (TWIN_ARGB32 , gif -> width , gif -> height );
586588 if (!anim -> frames [i ]) {
589+ /* Free previously allocated pixmaps */
590+ for (twin_count_t j = 0 ; j < i ; j ++ )
591+ twin_pixmap_destroy (anim -> frames [j ]);
592+ free (frame );
593+ free (anim -> frame_delays );
594+ free (anim -> frames );
587595 free (anim );
588596 gif_close (gif );
589597 return NULL ;
@@ -617,7 +625,12 @@ static twin_animation_t *_twin_animation_from_gif_file(const char *path)
617625 }
618626 anim -> iter = twin_animation_iter_init (anim );
619627 if (!anim -> iter ) {
628+ /* Free all allocated pixmaps */
629+ for (twin_count_t i = 0 ; i < frame_count ; i ++ )
630+ twin_pixmap_destroy (anim -> frames [i ]);
620631 free (frame );
632+ free (anim -> frame_delays );
633+ free (anim -> frames );
621634 free (anim );
622635 gif_close (gif );
623636 return NULL ;
You can’t perform that action at this time.
0 commit comments