From: Peter Johnson Date: Mon, 19 Nov 2001 04:15:22 +0000 (-0000) Subject: Fix a memory re-free issue in nasm_parser_directive(). vp->param was passed X-Git-Tag: v0.1.0~186 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9c7469116d4c5857f5c59af0a01f6503f02a54a1;p=yasm 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 --- 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 &&