mirror of
https://github.com/yasm/yasm
synced 2026-08-26 22:26:05 -04:00
gas preproc: Fix UB/crashes (#186)
This commit is contained in:
parent
93a960bc7d
commit
fa9e004383
1 changed files with 6 additions and 0 deletions
|
|
@ -912,6 +912,9 @@ static void expand_macro(yasm_preproc_gas *pp, macro_entry *macro, const char *a
|
|||
char *end = strstr(macro->params[j], "=");
|
||||
int len = (end ? (size_t)(end - macro->params[j])
|
||||
: strlen(macro->params[j]));
|
||||
if (!tokval.t_charptr) {
|
||||
continue;
|
||||
}
|
||||
if (!strncmp(tokval.t_charptr, macro->params[j], len)
|
||||
&& tokval.t_charptr[len] == '\0') {
|
||||
/* now, find matching argument. */
|
||||
|
|
@ -932,6 +935,9 @@ static void expand_macro(yasm_preproc_gas *pp, macro_entry *macro, const char *a
|
|||
memcpy(line + cursor - len, value, value_length);
|
||||
pp->expr.string = work = line;
|
||||
pp->expr.string_cursor += delta;
|
||||
if (pp->expr.symbol == tokval.t_charptr) {
|
||||
tokval.t_charptr = NULL;
|
||||
}
|
||||
if (pp->expr.symbol) {
|
||||
yasm_xfree(pp->expr.symbol);
|
||||
pp->expr.symbol = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue