From: Todd C. Miller Date: Tue, 27 Mar 2012 17:01:45 +0000 (-0400) Subject: Quiet a clang-analyzer false positive. X-Git-Tag: SUDO_1_8_5~1^2~115 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=12422f928cae6c508a3e53aad06017e8c74cc2a4;p=sudo Quiet a clang-analyzer false positive. --- diff --git a/plugins/sudoers/getdate.c b/plugins/sudoers/getdate.c index f8e8fc6dc..b577e9a4e 100644 --- a/plugins/sudoers/getdate.c +++ b/plugins/sudoers/getdate.c @@ -1052,7 +1052,7 @@ static int yygrowstack() #else #define YY_SIZE_MAX 0x7fffffff #endif - if (newsize && YY_SIZE_MAX / newsize < sizeof *newss) + if (!newsize || YY_SIZE_MAX / newsize < sizeof *newss) goto bail; newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) : (short *)malloc(newsize * sizeof *newss); /* overflow check above */ @@ -1060,7 +1060,7 @@ static int yygrowstack() goto bail; yyss = newss; yyssp = newss + i; - if (newsize && YY_SIZE_MAX / newsize < sizeof *newvs) + if (!newsize || YY_SIZE_MAX / newsize < sizeof *newvs) goto bail; newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) : (YYSTYPE *)malloc(newsize * sizeof *newvs); /* overflow check above */ diff --git a/plugins/sudoers/gram.c b/plugins/sudoers/gram.c index 62d6086b8..49c45c97f 100644 --- a/plugins/sudoers/gram.c +++ b/plugins/sudoers/gram.c @@ -849,9 +849,9 @@ static int yygrowstack() #ifdef SIZE_MAX #define YY_SIZE_MAX SIZE_MAX #else -#define YY_SIZE_MAX 0xffffffffU +#define YY_SIZE_MAX 0x7fffffff #endif - if (newsize && YY_SIZE_MAX / newsize < sizeof *newss) + if (!newsize || YY_SIZE_MAX / newsize < sizeof *newss) goto bail; newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) : (short *)malloc(newsize * sizeof *newss); /* overflow check above */ @@ -859,7 +859,7 @@ static int yygrowstack() goto bail; yyss = newss; yyssp = newss + i; - if (newsize && YY_SIZE_MAX / newsize < sizeof *newvs) + if (!newsize || YY_SIZE_MAX / newsize < sizeof *newvs) goto bail; newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) : (YYSTYPE *)malloc(newsize * sizeof *newvs); /* overflow check above */