From 8f6a910b2389271059858ff58cace5a0639472c8 Mon Sep 17 00:00:00 2001 From: BVK Chaitanya Date: Thu, 6 May 2010 09:55:06 +0530 Subject: [PATCH] fixed n > active_loops case --- include/grub/misc.h | 9 +++++++++ script/execute.c | 5 ++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/grub/misc.h b/include/grub/misc.h index 9bfc6974e..bcbcf33a3 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -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) { diff --git a/script/execute.c b/script/execute.c index 1f639e00b..3ad0b9dff 100644 --- a/script/execute.c +++ b/script/execute.c @@ -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; }