mirror of
https://github.com/netwide-assembler/nasm
synced 2026-08-26 16:23:04 -04:00
outas86.c: fix memory leak during initialization
It is just an O(1) memory leak but might as well fix it. filename_set_extension() returns a newly allocated string, as86_add_string() does not consume a string reference, so the string is left danging at the end; add nasm_free() to free it. Reported-by: <for-just-we@github.com> Fixes: https://github.com/netwide-assembler/nasm/issues/255 Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
parent
6051380c34
commit
5b9dce55cb
1 changed files with 5 additions and 1 deletions
|
|
@ -80,6 +80,8 @@ static void as86_sect_write(struct Section *, const uint8_t *,
|
|||
|
||||
static void as86_init(void)
|
||||
{
|
||||
char *module_name;
|
||||
|
||||
stext.data = saa_init(1L);
|
||||
stext.datalen = 0L;
|
||||
stext.head = stext.last = NULL;
|
||||
|
|
@ -101,7 +103,9 @@ static void as86_init(void)
|
|||
strslen = 0;
|
||||
|
||||
/* as86 module name = input file minus extension */
|
||||
as86_add_string(filename_set_extension(inname, ""));
|
||||
module_name = filename_set_extension(inname, "");
|
||||
as86_add_string(module_name);
|
||||
nasm_free(module_name);
|
||||
}
|
||||
|
||||
static void as86_cleanup(void)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue