diff options
author | H. Peter Anvin <hpa@zytor.com> | 2017-08-16 15:52:51 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2017-08-16 15:52:51 -0700 |
commit | 97fda4ce6ec6adfea3ec44527e96bd61208ec31f (patch) | |
tree | 68dd47e3b9cdaaf0222b18e19eba254459188c0b | |
parent | cf53dfbac4d42951378720af9a44df25f7538b53 (diff) | |
download | nasm-97fda4ce6ec6adfea3ec44527e96bd61208ec31f.tar.gz |
asm/preproc.c: use nasm_add_string_to_strlist()
Use nasm_add_string_to_strlist() to avoid a memory leak.
nasm_add_to_strlist() requires that the caller manages the string
being added or not.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | asm/preproc.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/asm/preproc.c b/asm/preproc.c index f06f400c..a8388bcb 100644 --- a/asm/preproc.c +++ b/asm/preproc.c @@ -1575,12 +1575,7 @@ static FILE *inc_fopen(const char *file, if (hp) { path = *hp; if (path || omode != INC_NEEDED) { - const char *name = path ? path : file; - size_t name_len = strlen(name); - sl = nasm_malloc(name_len + 1 + sizeof sl->next); - memcpy(sl->str, name, name_len+1); - sl->next = NULL; - nasm_add_to_strlist(dhead, sl); + nasm_add_string_to_strlist(dhead, path ? path : file); } } else { /* Need to do the actual path search */ |