From 3d7f4fe44148ca94dceabb631850971c582bff3f Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Sat, 21 Aug 2010 16:59:04 -0400 Subject: [PATCH] [animation] Properly handle zero animation frames In the event there are no animation frames, we should fail to load the animation control. --- src/libply-splash-graphics/ply-animation.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/libply-splash-graphics/ply-animation.c b/src/libply-splash-graphics/ply-animation.c index 772fc91b..53639186 100644 --- a/src/libply-splash-graphics/ply-animation.c +++ b/src/libply-splash-graphics/ply-animation.c @@ -237,7 +237,7 @@ ply_animation_add_frames (ply_animation_t *animation) number_of_entries = scandir (animation->image_dir, &entries, NULL, versionsort); - if (number_of_entries < 0) + if (number_of_entries <= 0) return false; load_finished = false; @@ -263,6 +263,13 @@ ply_animation_add_frames (ply_animation_t *animation) free (entries[i]); entries[i] = NULL; } + + if (ply_array_get_size (animation->frames) == 0) + { + ply_trace ("%s directory had no files starting with %s\n", + animation->image_dir, animation->frames_prefix); + goto out; + } load_finished = true; out: @@ -270,7 +277,7 @@ out: { ply_animation_remove_frames (animation); - while (entries[i] != NULL) + while (i < number_of_entries) { free (entries[i]); i++;