From 75fb22990f7cb4b64bbf621701deb98bf346df99 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 29 Mar 1999 04:31:16 +0000 Subject: [PATCH] Fix off by one error introduced in *alloc changes --- parse.yacc | 2 ++ sudo.tab.c | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/parse.yacc b/parse.yacc index 15bf137de..1d815a622 100644 --- a/parse.yacc +++ b/parse.yacc @@ -943,6 +943,8 @@ static void expand_match_list() if (++cm_list_len >= cm_list_size) { while ((cm_list_size += STACKINCREMENT) < cm_list_len) ; + if (cm_list == NULL) + cm_list_len = 0; /* start at 0 since it is a subscript */ cm_list = (struct command_match *) erealloc(cm_list, sizeof(struct command_match) * cm_list_size); } diff --git a/sudo.tab.c b/sudo.tab.c index 2a5f826fb..0b69ccf36 100644 --- a/sudo.tab.c +++ b/sudo.tab.c @@ -801,6 +801,8 @@ static void expand_match_list() if (++cm_list_len >= cm_list_size) { while ((cm_list_size += STACKINCREMENT) < cm_list_len) ; + if (cm_list == NULL) + cm_list_len = 0; /* start at 0 since it is a subscript */ cm_list = (struct command_match *) erealloc(cm_list, sizeof(struct command_match) * cm_list_size); } @@ -838,7 +840,7 @@ void init_parser() if (printmatches == TRUE) expand_match_list(); } -#line 842 "sudo.tab.c" +#line 844 "sudo.tab.c" /* allocate initial stack or double stack size, up to YYMAXDEPTH */ #if defined(__cplusplus) || __STDC__ static int yygrowstack(void) @@ -1508,7 +1510,7 @@ case 67: user_matches = TRUE; } break; -#line 1512 "sudo.tab.c" +#line 1514 "sudo.tab.c" } yyssp -= yym; yystate = *yyssp; -- 2.50.1