Addressed coverity issue 719941, missing varargs cleanup.

This commit is contained in:
Ward Fisher 2016-07-06 15:41:49 -06:00
parent 8507d923b7
commit 6d5a924354
6 changed files with 34 additions and 14 deletions

View File

@ -15,6 +15,15 @@ int error_count;
#define vastart(argv,fmt) va_start(argv)
#endif
/*
* Invalidate variable list.
*/
#ifndef NO_STDARG
#define vaend(argv,fmt) va_end(argv)
#else
#define vaend(argv,fmt) va_end(argv)
#endif
/*
* For logging error conditions.
* Designed to be called by other vararg procedures
@ -78,7 +87,7 @@ verror(fmt,va_alist) const char* fmt; va_dcl
strcpy(newfmt,"netCDF classic: not supported: ");
strncat(newfmt,fmt,2000);
vderror(newfmt,argv);
va_end(argv);
vaend(argv,fmt);
}
#ifndef NO_STDARG

View File

@ -16,6 +16,12 @@ extern int error_count;
#define vastart(argv,fmt) va_start(argv)
#endif
#ifndef NO_STDARG
#define vaend(argv,fmt) va_end(argv)
#else
#define vaend(argv,fmt) va_end(argv)
#endif
#ifndef NO_STDARG
#include <stdarg.h>
extern void vderror(const char *fmt, va_list argv);

View File

@ -879,6 +879,7 @@ yyerror(fmt,va_alist) const char* fmt; va_dcl
vastart(argv,fmt);
(void)fprintf(stderr,"%s: %s line %d: ", progname, cdlname, lineno);
vderror(fmt,argv);
vaend(argv,fmt);
}
/* undefine yywrap macro, in case we are using bison instead of yacc */

View File

@ -1,5 +1,5 @@
#line 3 "lex.ncg.c"
#line 3 "ncgenl.c"
#define YY_INT_ALIGNED short int
@ -1320,7 +1320,7 @@ ID ([A-Za-z_]|{UTF8})([A-Z.@#\[\]a-z_0-9+-]|{UTF8})*
/* Note: this definition of string will work for utf8 as well,
although it is a very relaxed definition
*/
#line 1324 "lex.ncg.c"
#line 1324 "ncgenl.c"
#define INITIAL 0
#define ST_C_COMMENT 1
@ -1506,7 +1506,7 @@ YY_DECL
#line 217 "ncgen.l"
#line 1510 "lex.ncg.c"
#line 1510 "ncgenl.c"
if ( !(yy_init) )
{
@ -1565,12 +1565,16 @@ yy_match:
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
while ( yy_current_state != 416 );
yy_cp = (yy_last_accepting_cpos);
yy_current_state = (yy_last_accepting_state);
while ( yy_base[yy_current_state] != 2347 );
yy_find_action:
yy_act = yy_accept[yy_current_state];
if ( yy_act == 0 )
{ /* have to back up */
yy_cp = (yy_last_accepting_cpos);
yy_current_state = (yy_last_accepting_state);
yy_act = yy_accept[yy_current_state];
}
YY_DO_BEFORE_ACTION;
@ -2115,7 +2119,7 @@ YY_RULE_SETUP
#line 570 "ncgen.l"
ECHO;
YY_BREAK
#line 2119 "lex.ncg.c"
#line 2123 "ncgenl.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(TEXT):
yyterminate();
@ -2183,8 +2187,7 @@ case YY_STATE_EOF(TEXT):
else
{
yy_cp = (yy_last_accepting_cpos);
yy_current_state = (yy_last_accepting_state);
yy_cp = (yy_c_buf_p);
goto yy_find_action;
}
}

View File

@ -338,7 +338,7 @@ Datalist* datalist;
NCConstant constant;
}
/* Line 193 of yacc.c. */
#line 342 "ncgen.tab.c"
#line 342 "ncgeny.c"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
@ -351,7 +351,7 @@ NCConstant constant;
/* Line 216 of yacc.c. */
#line 355 "ncgen.tab.c"
#line 355 "ncgeny.c"
#ifdef short
# undef short
@ -2732,7 +2732,7 @@ fprintf(stderr,"dimension: %s = UNLIMITED\n",(yyvsp[(1) - (3)].sym)->name);
/* Line 1267 of yacc.c. */
#line 2736 "ncgen.tab.c"
#line 2736 "ncgeny.c"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@ -2961,6 +2961,7 @@ yyerror(fmt,va_alist) const char* fmt; va_dcl
vastart(argv,fmt);
(void)fprintf(stderr,"%s: %s line %d: ", progname, cdlname, lineno);
vderror(fmt,argv);
vaend(argv,fmt);
}
/* undefine yywrap macro, in case we are using bison instead of yacc */

View File

@ -160,7 +160,7 @@ Datalist* datalist;
NCConstant constant;
}
/* Line 1529 of yacc.c. */
#line 164 "ncgen.tab.h"
#line 164 "ncgeny.h"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1