0
0
forked from aniani/nasm

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>
This commit is contained in:
H. Peter Anvin
2017-08-16 15:52:51 -07:00
parent cf53dfbac4
commit 97fda4ce6e

View File

@@ -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 */