fixed n > active_loops case

This commit is contained in:
BVK Chaitanya 2010-05-06 09:55:06 +05:30
parent a7aa28248b
commit 8f6a910b23
2 changed files with 11 additions and 3 deletions

View 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)
{

View 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;
}