]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
fixed n > active_loops case
authorBVK Chaitanya <bvk.groups@gmail.com>
Thu, 6 May 2010 04:25:06 +0000 (09:55 +0530)
committerBVK Chaitanya <bvk.groups@gmail.com>
Thu, 6 May 2010 04:25:06 +0000 (09:55 +0530)
include/grub/misc.h
script/execute.c

index 9bfc6974e8127bfce4501ab1477e691569c2aa6f..bcbcf33a3f99184f5d4d1e4010425378eaad989c 100644 (file)
@@ -281,6 +281,15 @@ grub_abs (int x)
     return (unsigned int) x;
 }
 
+static inline long
+grub_min (long x, long y)
+{
+  if (x < y)
+    return x;
+  else
+    return y;
+}
+
 static inline long
 grub_max (long x, long y)
 {
index 1f639e00ba0d0a58a30b2a880c5f0aba2f3ac84d..3ad0b9dffc53f2a480256dba9fe2d5a549326ffd 100644 (file)
@@ -44,12 +44,11 @@ grub_script_break (grub_command_t cmd __attribute__((unused)),
   if (argc == 0)
     count = 1;
 
-  else if ((argc > 1) ||
-          (count = grub_strtoul (argv[0], &p, 10)) > active_loops ||
+  else if ((argc > 1) || (count = grub_strtoul (argv[0], &p, 10)) == 0 ||
           (*p != '\0'))
     return grub_error (GRUB_ERR_BAD_ARGUMENT, "bad break");
 
-  active_breaks = count;
+  active_breaks = grub_min (active_loops, count);
   return GRUB_ERR_NONE;
 }