From 3448f8698603eaf50db47113315815da4e93f0d5 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Tue, 28 Sep 2010 21:24:17 +0200 Subject: [PATCH] bug #335: Solves seg fault in scheduler with empty strings --- src/scheduler/src/xml/expr_bool.cc | 28 ++++++++++++++-------------- src/scheduler/src/xml/expr_bool.h | 6 +++--- src/scheduler/src/xml/expr_bool.y | 8 ++++---- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/scheduler/src/xml/expr_bool.cc b/src/scheduler/src/xml/expr_bool.cc index d1b86f1d85..0d9c80598f 100644 --- a/src/scheduler/src/xml/expr_bool.cc +++ b/src/scheduler/src/xml/expr_bool.cc @@ -1,9 +1,9 @@ -/* A Bison parser, made by GNU Bison 2.4.2. */ +/* A Bison parser, made by GNU Bison 2.4.3. */ /* Skeleton implementation for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software - Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -45,7 +45,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.2" +#define YYBISON_VERSION "2.4.3" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -1243,7 +1243,7 @@ YYLTYPE yylloc; YYLTYPE *yylsp; /* The locations where the error started and ended. */ - YYLTYPE yyerror_range[2]; + YYLTYPE yyerror_range[3]; YYSIZE_T yystacksize; @@ -1556,7 +1556,7 @@ yyreduce: /* Line 1464 of yacc.c */ #line 137 "expr_bool.y" - {float val; + { float val; get_xml_attribute(oxml,(yyvsp[(1) - (3)].val_str),val); (yyval.val_int) = val > (yyvsp[(3) - (3)].val_float);;} @@ -1566,7 +1566,7 @@ yyreduce: /* Line 1464 of yacc.c */ #line 142 "expr_bool.y" - {float val; + { float val; get_xml_attribute(oxml,(yyvsp[(1) - (3)].val_str),val); (yyval.val_int) = val < (yyvsp[(3) - (3)].val_float);;} @@ -1579,7 +1579,7 @@ yyreduce: { string val; get_xml_attribute(oxml,(yyvsp[(1) - (3)].val_str),val); - (yyval.val_int) = val.empty() ? false :fnmatch((yyvsp[(3) - (3)].val_str), val.c_str(), 0) == 0;;} + (yyval.val_int) = (val.empty() || (yyvsp[(3) - (3)].val_str)==0) ? false : fnmatch((yyvsp[(3) - (3)].val_str),val.c_str(),0)==0;;} break; case 13: @@ -1589,7 +1589,7 @@ yyreduce: { string val; get_xml_attribute(oxml,(yyvsp[(1) - (4)].val_str),val); - (yyval.val_int) = val.empty() ? false : fnmatch((yyvsp[(4) - (4)].val_str), val.c_str(), 0) != 0;;} + (yyval.val_int) = (val.empty() || (yyvsp[(4) - (4)].val_str)==0) ? false : fnmatch((yyvsp[(4) - (4)].val_str),val.c_str(),0)!=0;;} break; case 14: @@ -1695,7 +1695,7 @@ yyerrlab: #endif } - yyerror_range[0] = yylloc; + yyerror_range[1] = yylloc; if (yyerrstatus == 3) { @@ -1732,7 +1732,7 @@ yyerrorlab: if (/*CONSTCOND*/ 0) goto yyerrorlab; - yyerror_range[0] = yylsp[1-yylen]; + yyerror_range[1] = yylsp[1-yylen]; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); @@ -1766,7 +1766,7 @@ yyerrlab1: if (yyssp == yyss) YYABORT; - yyerror_range[0] = *yylsp; + yyerror_range[1] = *yylsp; yydestruct ("Error: popping", yystos[yystate], yyvsp, yylsp, mc, oxml, result, error_msg); YYPOPSTACK (1); @@ -1776,10 +1776,10 @@ yyerrlab1: *++yyvsp = yylval; - yyerror_range[1] = yylloc; + yyerror_range[2] = yylloc; /* Using YYLLOC is tempting, but would change the location of the lookahead. YYLOC is available though. */ - YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); + YYLLOC_DEFAULT (yyloc, yyerror_range, 2); *++yylsp = yyloc; /* Shift the error token. */ diff --git a/src/scheduler/src/xml/expr_bool.h b/src/scheduler/src/xml/expr_bool.h index 41d20a621f..3e0c95e1f6 100644 --- a/src/scheduler/src/xml/expr_bool.h +++ b/src/scheduler/src/xml/expr_bool.h @@ -1,9 +1,9 @@ -/* A Bison parser, made by GNU Bison 2.4.2. */ +/* A Bison parser, made by GNU Bison 2.4.3. */ /* Skeleton interface for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software - Foundation, Inc. + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/scheduler/src/xml/expr_bool.y b/src/scheduler/src/xml/expr_bool.y index 0a1bb7199c..fc7adc891d 100644 --- a/src/scheduler/src/xml/expr_bool.y +++ b/src/scheduler/src/xml/expr_bool.y @@ -134,12 +134,12 @@ expr: STRING '=' INTEGER { int val; get_xml_attribute(oxml,$1,val); $$ = val != $4;} - | STRING '>' FLOAT {float val; + | STRING '>' FLOAT { float val; get_xml_attribute(oxml,$1,val); $$ = val > $3;} - | STRING '<' FLOAT {float val; + | STRING '<' FLOAT { float val; get_xml_attribute(oxml,$1,val); $$ = val < $3;} @@ -147,12 +147,12 @@ expr: STRING '=' INTEGER { int val; | STRING '=' STRING { string val; get_xml_attribute(oxml,$1,val); - $$ = val.empty() ? false :fnmatch($3, val.c_str(), 0) == 0;} + $$ = (val.empty() || $3==0) ? false : fnmatch($3,val.c_str(),0)==0;} | STRING '!''=' STRING { string val; get_xml_attribute(oxml,$1,val); - $$ = val.empty() ? false : fnmatch($4, val.c_str(), 0) != 0;} + $$ = (val.empty() || $4==0) ? false : fnmatch($4,val.c_str(),0)!=0;} | expr '&' expr { $$ = $1 && $3; } | expr '|' expr { $$ = $1 || $3; }