From 97fda4ce6ec6adfea3ec44527e96bd61208ec31f Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Wed, 16 Aug 2017 15:52:51 -0700 Subject: [PATCH] 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 --- asm/preproc.c | 7 +------ 1 file changed, 1 insertion(+), 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 */