Don't use pParser->yyidx as an index into pParser->yystack[] until after it is
authorcmaynard <cmaynard@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 1 Apr 2011 16:55:59 +0000 (16:55 +0000)
committercmaynard <cmaynard@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 1 Apr 2011 16:55:59 +0000 (16:55 +0000)
verified that it is non-negative.  Should resolve CID 619.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@36431 f5534014-38df-0310-8fa8-9805f1628bb7

tools/lemon/lempar.c

index 6ac188097ce262bc670e98db65428a4e287ad208..72e5f6018ed6af126ff34b6634e616aac8064521 100644 (file)
@@ -327,11 +327,12 @@ static void yy_destructor(YYCODETYPE yymajor, YYMINORTYPE *yypminor){
 */
 static int yy_pop_parser_stack(yyParser *pParser){
   YYCODETYPE yymajor;
-  yyStackEntry *yytos = &pParser->yystack[pParser->yyidx];
+  yyStackEntry *yytos;
 
   if( pParser->yyidx<0 ) return 0;
+  yytos = &pParser->yystack[pParser->yyidx];
 #ifndef NDEBUG
-  if( yyTraceFILE && pParser->yyidx>=0 ){
+  if( yyTraceFILE ){
     fprintf(yyTraceFILE,"%sPopping %s\n",
       yyTracePrompt,
      yyTokenName[yytos->major]);