mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-07-24 10:25:42 -04:00
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:
parent
cf53dfbac4
commit
97fda4ce6e
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user