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)
576
576
uint8_t * color , * frame ;
577
577
frame = malloc (gif -> width * gif -> height * 3 );
578
578
if (!frame ) {
579
+ free (anim -> frame_delays );
580
+ free (anim -> frames );
579
581
free (anim );
580
582
gif_close (gif );
581
583
return NULL ;
@@ -584,6 +586,12 @@ static twin_animation_t *_twin_animation_from_gif_file(const char *path)
584
586
anim -> frames [i ] =
585
587
twin_pixmap_create (TWIN_ARGB32 , gif -> width , gif -> height );
586
588
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 );
587
595
free (anim );
588
596
gif_close (gif );
589
597
return NULL ;
@@ -617,7 +625,12 @@ static twin_animation_t *_twin_animation_from_gif_file(const char *path)
617
625
}
618
626
anim -> iter = twin_animation_iter_init (anim );
619
627
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 ]);
620
631
free (frame );
632
+ free (anim -> frame_delays );
633
+ free (anim -> frames );
621
634
free (anim );
622
635
gif_close (gif );
623
636
return NULL ;
You can’t perform that action at this time.
0 commit comments