Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix memory leak of MMacro::name on macro undefining #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions asm/preproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3318,6 +3318,7 @@ static bool parse_mmacro_spec(Token *tline, MMacro *def, const char *directive)
#if 0
def->prev = NULL;
#endif
nasm_assert(!def->name);
def->name = dup_text(tline);
def->plus = false;
def->nolist = 0;
Expand Down Expand Up @@ -4615,12 +4616,14 @@ static int do_directive(Token *tline, Token **output)
if (!mmac_p) {
/* No such macro */
free_tlist(spec.dlist);
nasm_free(spec.name);
break;
}

/* Check the macro to be undefined is not being expanded */
list_for_each(l, istk->expansion) {
if (l->finishes == *mmac_p) {
nasm_free(spec.name);
nasm_nonfatal("`%%unmacro' can't undefine the macro being expanded");
/*
* Do not release the macro instance to avoid using the freed
Expand All @@ -4644,6 +4647,7 @@ static int do_directive(Token *tline, Token **output)
}
}
free_tlist(spec.dlist);
nasm_free(spec.name);
break;
}

Expand Down