]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
[animation] Properly handle zero animation frames
authorRay Strode <rstrode@redhat.com>
Sat, 21 Aug 2010 20:59:04 +0000 (16:59 -0400)
committerRay Strode <rstrode@redhat.com>
Sat, 21 Aug 2010 20:59:04 +0000 (16:59 -0400)
In the event there are no animation frames, we should
fail to load the animation control.

src/libply-splash-graphics/ply-animation.c

index 772fc91b86fed94c7607d581e0991611779b4398..53639186b5cbfd0a1b593ebde46ec398dc2dda8b 100644 (file)
@@ -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++;