From 9c7469116d4c5857f5c59af0a01f6503f02a54a1 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Mon, 19 Nov 2001 04:15:22 +0000 Subject: [PATCH] Fix a memory re-free issue in nasm_parser_directive(). vp->param was passed to a function that keeps the pointer, and then the pointer is freed. Whoops! svn path=/trunk/yasm/; revision=344 --- modules/parsers/nasm/bison.y.in | 12 +++++++++--- modules/parsers/nasm/nasm-bison.y | 12 +++++++++--- src/parsers/nasm/bison.y.in | 12 +++++++++--- src/parsers/nasm/nasm-bison.y | 12 +++++++++--- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/modules/parsers/nasm/bison.y.in b/modules/parsers/nasm/bison.y.in index 4317140e..a4aa433e 100644 --- a/modules/parsers/nasm/bison.y.in +++ b/modules/parsers/nasm/bison.y.in @@ -621,9 +621,15 @@ nasm_parser_directive(const char *name, valparamhead *valparams, Error(_("invalid argument to [%s]"), "SECTION"); } else if (strcasecmp(name, "absolute") == 0) { vp = vps_first(valparams); - nasm_parser_cur_section = - sections_switch_absolute(&nasm_parser_sections, vp->val ? - expr_new_ident(ExprSym(symrec_use(vp->val))) : vp->param); + if (vp->val) + nasm_parser_cur_section = + sections_switch_absolute(&nasm_parser_sections, + expr_new_ident(ExprSym(symrec_use(vp->val)))); + else if (vp->param) { + nasm_parser_cur_section = + sections_switch_absolute(&nasm_parser_sections, vp->param); + vp->param = NULL; + } nasm_parser_prev_bc = (bytecode *)NULL; } else if (strcasecmp(name, "bits") == 0) { if ((vp = vps_first(valparams)) && !vp->val && vp->param != NULL && diff --git a/modules/parsers/nasm/nasm-bison.y b/modules/parsers/nasm/nasm-bison.y index 4317140e..a4aa433e 100644 --- a/modules/parsers/nasm/nasm-bison.y +++ b/modules/parsers/nasm/nasm-bison.y @@ -621,9 +621,15 @@ nasm_parser_directive(const char *name, valparamhead *valparams, Error(_("invalid argument to [%s]"), "SECTION"); } else if (strcasecmp(name, "absolute") == 0) { vp = vps_first(valparams); - nasm_parser_cur_section = - sections_switch_absolute(&nasm_parser_sections, vp->val ? - expr_new_ident(ExprSym(symrec_use(vp->val))) : vp->param); + if (vp->val) + nasm_parser_cur_section = + sections_switch_absolute(&nasm_parser_sections, + expr_new_ident(ExprSym(symrec_use(vp->val)))); + else if (vp->param) { + nasm_parser_cur_section = + sections_switch_absolute(&nasm_parser_sections, vp->param); + vp->param = NULL; + } nasm_parser_prev_bc = (bytecode *)NULL; } else if (strcasecmp(name, "bits") == 0) { if ((vp = vps_first(valparams)) && !vp->val && vp->param != NULL && diff --git a/src/parsers/nasm/bison.y.in b/src/parsers/nasm/bison.y.in index 4317140e..a4aa433e 100644 --- a/src/parsers/nasm/bison.y.in +++ b/src/parsers/nasm/bison.y.in @@ -621,9 +621,15 @@ nasm_parser_directive(const char *name, valparamhead *valparams, Error(_("invalid argument to [%s]"), "SECTION"); } else if (strcasecmp(name, "absolute") == 0) { vp = vps_first(valparams); - nasm_parser_cur_section = - sections_switch_absolute(&nasm_parser_sections, vp->val ? - expr_new_ident(ExprSym(symrec_use(vp->val))) : vp->param); + if (vp->val) + nasm_parser_cur_section = + sections_switch_absolute(&nasm_parser_sections, + expr_new_ident(ExprSym(symrec_use(vp->val)))); + else if (vp->param) { + nasm_parser_cur_section = + sections_switch_absolute(&nasm_parser_sections, vp->param); + vp->param = NULL; + } nasm_parser_prev_bc = (bytecode *)NULL; } else if (strcasecmp(name, "bits") == 0) { if ((vp = vps_first(valparams)) && !vp->val && vp->param != NULL && diff --git a/src/parsers/nasm/nasm-bison.y b/src/parsers/nasm/nasm-bison.y index 4317140e..a4aa433e 100644 --- a/src/parsers/nasm/nasm-bison.y +++ b/src/parsers/nasm/nasm-bison.y @@ -621,9 +621,15 @@ nasm_parser_directive(const char *name, valparamhead *valparams, Error(_("invalid argument to [%s]"), "SECTION"); } else if (strcasecmp(name, "absolute") == 0) { vp = vps_first(valparams); - nasm_parser_cur_section = - sections_switch_absolute(&nasm_parser_sections, vp->val ? - expr_new_ident(ExprSym(symrec_use(vp->val))) : vp->param); + if (vp->val) + nasm_parser_cur_section = + sections_switch_absolute(&nasm_parser_sections, + expr_new_ident(ExprSym(symrec_use(vp->val)))); + else if (vp->param) { + nasm_parser_cur_section = + sections_switch_absolute(&nasm_parser_sections, vp->param); + vp->param = NULL; + } nasm_parser_prev_bc = (bytecode *)NULL; } else if (strcasecmp(name, "bits") == 0) { if ((vp = vps_first(valparams)) && !vp->val && vp->param != NULL && -- 2.40.0