diff options
author | cryptobro <andrey.roussev@gmail.com> | 2023-05-13 07:12:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-12 21:12:54 -0700 |
commit | fa9e004383690ce2a0de70976cc9b9ef58bf2b03 (patch) | |
tree | b146253ef432cc00e3d084cd2ba4738b07e71127 | |
parent | 93a960bc7da77eceb868d0dd5886c6fb844daee0 (diff) | |
download | yasm-fa9e004383690ce2a0de70976cc9b9ef58bf2b03.tar.gz |
gas preproc: Fix UB/crashes (#186)
-rw-r--r-- | modules/preprocs/gas/gas-preproc.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/preprocs/gas/gas-preproc.c b/modules/preprocs/gas/gas-preproc.c index 94d8f5da..8f4c7932 100644 --- a/modules/preprocs/gas/gas-preproc.c +++ b/modules/preprocs/gas/gas-preproc.c @@ -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; |