From c768b9256ae22de6615ade351d92d4ee038ccaa2 Mon Sep 17 00:00:00 2001 From: urchlay Date: Sat, 23 Jul 2005 21:16:57 +0000 Subject: [PATCH] Fixed segfaults when using commands that take a filename. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@692 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/debugger/DebuggerParser.cxx | 4 +- stella/src/yacc/YaccParser.cxx | 4 +- stella/src/yacc/stella.y | 6 +- stella/src/yacc/y.tab.c | 86 ++++++++++++++------------ 4 files changed, 55 insertions(+), 45 deletions(-) diff --git a/stella/src/debugger/DebuggerParser.cxx b/stella/src/debugger/DebuggerParser.cxx index 6eca3114a..e510d7bb6 100644 --- a/stella/src/debugger/DebuggerParser.cxx +++ b/stella/src/debugger/DebuggerParser.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DebuggerParser.cxx,v 1.69 2005-07-23 19:07:15 urchlay Exp $ +// $Id: DebuggerParser.cxx,v 1.70 2005-07-23 21:16:57 urchlay Exp $ //============================================================================ #include "bspf.hxx" @@ -1167,7 +1167,7 @@ bool DebuggerParser::saveScriptFile(string file) { StringList conds = debugger->cpuDebug().m6502().getCondBreakNames(); for(unsigned int i=0; i(lastExp)) delete lastExp; + + lastExp = 0; } %} diff --git a/stella/src/yacc/y.tab.c b/stella/src/yacc/y.tab.c index d652477d8..02f2c7f72 100644 --- a/stella/src/yacc/y.tab.c +++ b/stella/src/yacc/y.tab.c @@ -36,12 +36,16 @@ void yyerror(char *e) { //fprintf(stderr, "%s at token \"%s\"\n", e, yytext); fprintf(stderr, "%s\n", e); errMsg = e; - if(lastExp) + + // be extra paranoid about deletion + if(lastExp && dynamic_cast(lastExp)) delete lastExp; + + lastExp = 0; } -#line 21 "stella.y" +#line 25 "stella.y" #ifndef YYSTYPE typedef union { int val; @@ -130,10 +134,10 @@ static const short yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const short yyrline[] = { - 0, 57, 60, 61, 62, 63, 64, 65, 66, 67, - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, - 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, 92 + 0, 61, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, + 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, + 92, 93, 94, 95, 96 }; #endif @@ -969,139 +973,139 @@ yyreduce: switch (yyn) { case 1: -#line 57 "stella.y" +#line 61 "stella.y" { fprintf(stderr, "\ndone\n"); result.exp = yyvsp[0].exp; } break; case 2: -#line 60 "stella.y" +#line 64 "stella.y" { fprintf(stderr, " +"); yyval.exp = new PlusExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } break; case 3: -#line 61 "stella.y" +#line 65 "stella.y" { fprintf(stderr, " -"); yyval.exp = new MinusExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } break; case 4: -#line 62 "stella.y" +#line 66 "stella.y" { fprintf(stderr, " *"); yyval.exp = new MultExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } break; case 5: -#line 63 "stella.y" +#line 67 "stella.y" { fprintf(stderr, " /"); yyval.exp = new DivExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } break; case 6: -#line 64 "stella.y" +#line 68 "stella.y" { fprintf(stderr, " %%"); yyval.exp = new ModExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } break; case 7: -#line 65 "stella.y" +#line 69 "stella.y" { fprintf(stderr, " &"); yyval.exp = new BinAndExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } break; case 8: -#line 66 "stella.y" +#line 70 "stella.y" { fprintf(stderr, " |"); yyval.exp = new BinOrExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } break; case 9: -#line 67 "stella.y" +#line 71 "stella.y" { fprintf(stderr, " ^"); yyval.exp = new BinXorExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } break; case 10: -#line 68 "stella.y" +#line 72 "stella.y" { fprintf(stderr, " <"); yyval.exp = new LessExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } break; case 11: -#line 69 "stella.y" +#line 73 "stella.y" { fprintf(stderr, " >"); yyval.exp = new GreaterExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } break; case 12: -#line 70 "stella.y" +#line 74 "stella.y" { fprintf(stderr, " >="); yyval.exp = new GreaterEqualsExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } break; case 13: -#line 71 "stella.y" +#line 75 "stella.y" { fprintf(stderr, " <="); yyval.exp = new LessEqualsExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } break; case 14: -#line 72 "stella.y" +#line 76 "stella.y" { fprintf(stderr, " !="); yyval.exp = new NotEqualsExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } break; case 15: -#line 73 "stella.y" +#line 77 "stella.y" { fprintf(stderr, " =="); yyval.exp = new EqualsExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } break; case 16: -#line 74 "stella.y" +#line 78 "stella.y" { fprintf(stderr, " >>"); yyval.exp = new ShiftRightExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } break; case 17: -#line 75 "stella.y" +#line 79 "stella.y" { fprintf(stderr, " <<"); yyval.exp = new ShiftLeftExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } break; case 18: -#line 76 "stella.y" +#line 80 "stella.y" { fprintf(stderr, " ||"); yyval.exp = new LogOrExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } break; case 19: -#line 77 "stella.y" +#line 81 "stella.y" { fprintf(stderr, " &&"); yyval.exp = new LogAndExpression(yyvsp[-2].exp, yyvsp[0].exp); lastExp = yyval.exp; } break; case 20: -#line 78 "stella.y" +#line 82 "stella.y" { fprintf(stderr, " U-"); yyval.exp = new UnaryMinusExpression(yyvsp[0].exp); lastExp = yyval.exp; } break; case 21: -#line 79 "stella.y" +#line 83 "stella.y" { fprintf(stderr, " ~"); yyval.exp = new BinNotExpression(yyvsp[0].exp); lastExp = yyval.exp; } break; case 22: -#line 80 "stella.y" +#line 84 "stella.y" { fprintf(stderr, " !"); yyval.exp = new LogNotExpression(yyvsp[0].exp); lastExp = yyval.exp; } break; case 23: -#line 81 "stella.y" +#line 85 "stella.y" { fprintf(stderr, " U*"); yyval.exp = new ByteDerefExpression(yyvsp[0].exp); lastExp = yyval.exp; } break; case 24: -#line 82 "stella.y" +#line 86 "stella.y" { fprintf(stderr, " U@"); yyval.exp = new WordDerefExpression(yyvsp[0].exp); lastExp = yyval.exp; } break; case 25: -#line 83 "stella.y" +#line 87 "stella.y" { fprintf(stderr, " U<"); yyval.exp = new LoByteExpression(yyvsp[0].exp); lastExp = yyval.exp; } break; case 26: -#line 84 "stella.y" +#line 88 "stella.y" { fprintf(stderr, " U>"); yyval.exp = new HiByteExpression(yyvsp[0].exp); lastExp = yyval.exp; } break; case 27: -#line 85 "stella.y" +#line 89 "stella.y" { fprintf(stderr, " ()"); yyval.exp = yyvsp[-1].exp; lastExp = yyval.exp; } break; case 28: -#line 86 "stella.y" +#line 90 "stella.y" { fprintf(stderr, " []"); yyval.exp = new ByteDerefOffsetExpression(yyvsp[-3].exp, yyvsp[-1].exp); lastExp = yyval.exp; } break; case 29: -#line 87 "stella.y" +#line 91 "stella.y" { fprintf(stderr, " %d", yyvsp[0].val); yyval.exp = new ConstExpression(yyvsp[0].val); lastExp = yyval.exp; } break; case 30: -#line 88 "stella.y" +#line 92 "stella.y" { fprintf(stderr, " %s", yyvsp[0].equate); yyval.exp = new EquateExpression(yyvsp[0].equate); lastExp = yyval.exp; } break; case 31: -#line 89 "stella.y" +#line 93 "stella.y" { fprintf(stderr, " (CpuMethod)"); yyval.exp = new CpuMethodExpression(yyvsp[0].cpuMethod); lastExp = yyval.exp; } break; case 32: -#line 90 "stella.y" +#line 94 "stella.y" { fprintf(stderr, " (TiaMethod)"); yyval.exp = new TiaMethodExpression(yyvsp[0].tiaMethod); lastExp = yyval.exp; } break; case 33: -#line 91 "stella.y" +#line 95 "stella.y" { fprintf(stderr, " (function)"); yyval.exp = new FunctionExpression(yyvsp[0].function); lastExp = yyval.exp; } break; case 34: -#line 92 "stella.y" +#line 96 "stella.y" { fprintf(stderr, " ERR"); yyerror("Invalid label or constant"); return 1; } break; } @@ -1337,5 +1341,5 @@ yyreturn: #endif return yyresult; } -#line 94 "stella.y" +#line 98 "stella.y"