From: Peter Johnson Date: Thu, 1 Nov 2001 00:24:09 +0000 (-0000) Subject: Fix directive memory leaks in a different way; the old way broke name/val X-Git-Tag: v0.1.0~223 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1d26b1de84d8263eb3a3d46417c62cf4de619dfa;p=yasm Fix directive memory leaks in a different way; the old way broke name/val splitting. svn path=/trunk/yasm/; revision=307 --- diff --git a/modules/parsers/nasm/bison.y.in b/modules/parsers/nasm/bison.y.in index 9846e2cf..4b3754e4 100644 --- a/modules/parsers/nasm/bison.y.in +++ b/modules/parsers/nasm/bison.y.in @@ -217,12 +217,17 @@ label_id: ID { /* directives */ directive: '[' DIRECTIVE_NAME DIRECTIVE_VAL ']' { nasm_parser_directive($2, $3); + xfree($2); + xfree($3); } | '[' DIRECTIVE_NAME DIRECTIVE_VAL error { Error(_("missing `%c'"), ']'); + xfree($2); + xfree($3); } | '[' DIRECTIVE_NAME error { Error(_("missing argument to `%s'"), $2); + xfree($2); } ; diff --git a/modules/parsers/nasm/nasm-bison.y b/modules/parsers/nasm/nasm-bison.y index 9846e2cf..4b3754e4 100644 --- a/modules/parsers/nasm/nasm-bison.y +++ b/modules/parsers/nasm/nasm-bison.y @@ -217,12 +217,17 @@ label_id: ID { /* directives */ directive: '[' DIRECTIVE_NAME DIRECTIVE_VAL ']' { nasm_parser_directive($2, $3); + xfree($2); + xfree($3); } | '[' DIRECTIVE_NAME DIRECTIVE_VAL error { Error(_("missing `%c'"), ']'); + xfree($2); + xfree($3); } | '[' DIRECTIVE_NAME error { Error(_("missing argument to `%s'"), $2); + xfree($2); } ; diff --git a/modules/parsers/nasm/token.l.in b/modules/parsers/nasm/token.l.in index b868b678..6973afbe 100644 --- a/modules/parsers/nasm/token.l.in +++ b/modules/parsers/nasm/token.l.in @@ -177,12 +177,12 @@ WS [ \t\r] [a-z]+ { BEGIN DIRECTIVE2; - yylval.str_val = yytext; + yylval.str_val = xstrdup(yytext); return DIRECTIVE_NAME; } /* everything printable except for ' ', '[' and ']'. */ [!-@a-z\\^-`{|}~]+ { - yylval.str_val = yytext; + yylval.str_val = xstrdup(yytext); return DIRECTIVE_VAL; } . { diff --git a/src/parsers/nasm/bison.y.in b/src/parsers/nasm/bison.y.in index 9846e2cf..4b3754e4 100644 --- a/src/parsers/nasm/bison.y.in +++ b/src/parsers/nasm/bison.y.in @@ -217,12 +217,17 @@ label_id: ID { /* directives */ directive: '[' DIRECTIVE_NAME DIRECTIVE_VAL ']' { nasm_parser_directive($2, $3); + xfree($2); + xfree($3); } | '[' DIRECTIVE_NAME DIRECTIVE_VAL error { Error(_("missing `%c'"), ']'); + xfree($2); + xfree($3); } | '[' DIRECTIVE_NAME error { Error(_("missing argument to `%s'"), $2); + xfree($2); } ; diff --git a/src/parsers/nasm/nasm-bison.y b/src/parsers/nasm/nasm-bison.y index 9846e2cf..4b3754e4 100644 --- a/src/parsers/nasm/nasm-bison.y +++ b/src/parsers/nasm/nasm-bison.y @@ -217,12 +217,17 @@ label_id: ID { /* directives */ directive: '[' DIRECTIVE_NAME DIRECTIVE_VAL ']' { nasm_parser_directive($2, $3); + xfree($2); + xfree($3); } | '[' DIRECTIVE_NAME DIRECTIVE_VAL error { Error(_("missing `%c'"), ']'); + xfree($2); + xfree($3); } | '[' DIRECTIVE_NAME error { Error(_("missing argument to `%s'"), $2); + xfree($2); } ; diff --git a/src/parsers/nasm/token.l.in b/src/parsers/nasm/token.l.in index b868b678..6973afbe 100644 --- a/src/parsers/nasm/token.l.in +++ b/src/parsers/nasm/token.l.in @@ -177,12 +177,12 @@ WS [ \t\r] [a-z]+ { BEGIN DIRECTIVE2; - yylval.str_val = yytext; + yylval.str_val = xstrdup(yytext); return DIRECTIVE_NAME; } /* everything printable except for ' ', '[' and ']'. */ [!-@a-z\\^-`{|}~]+ { - yylval.str_val = yytext; + yylval.str_val = xstrdup(yytext); return DIRECTIVE_VAL; } . {