From: Ray Strode Date: Sat, 21 Aug 2010 20:59:04 +0000 (-0400) Subject: [animation] Properly handle zero animation frames X-Git-Tag: 0.8.4~166 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3d7f4fe44148ca94dceabb631850971c582bff3f;p=thirdparty%2Fplymouth.git [animation] Properly handle zero animation frames In the event there are no animation frames, we should fail to load the animation control. --- 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++;