mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-10-10 00:25:06 -04:00
output/codeview.c: use list_for_each_safe() to free a list
Using list_for_each() is by definition not safe when freeing the members of the list, use list_for_each_free() instead. Also, use nasm_new() and nasm_free() where appropriate. This was discovered as a downstream bug from BR 3392707. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
@@ -305,7 +305,7 @@ static void build_type_table(struct coff_Section *const sect);
|
|||||||
static void cv8_cleanup(void)
|
static void cv8_cleanup(void)
|
||||||
{
|
{
|
||||||
struct cv8_symbol *sym;
|
struct cv8_symbol *sym;
|
||||||
struct source_file *file;
|
struct source_file *file, *ftmp;
|
||||||
|
|
||||||
struct coff_Section *symbol_sect = coff_sects[cv8_state.symbol_sect];
|
struct coff_Section *symbol_sect = coff_sects[cv8_state.symbol_sect];
|
||||||
struct coff_Section *type_sect = coff_sects[cv8_state.type_sect];
|
struct coff_Section *type_sect = coff_sects[cv8_state.type_sect];
|
||||||
@@ -316,10 +316,10 @@ static void cv8_cleanup(void)
|
|||||||
build_symbol_table(symbol_sect);
|
build_symbol_table(symbol_sect);
|
||||||
build_type_table(type_sect);
|
build_type_table(type_sect);
|
||||||
|
|
||||||
list_for_each(file, cv8_state.source_files) {
|
list_for_each_safe(file, ftmp, cv8_state.source_files) {
|
||||||
nasm_free(file->fullname);
|
nasm_free(file->fullname);
|
||||||
saa_free(file->lines);
|
saa_free(file->lines);
|
||||||
free(file);
|
nasm_free(file);
|
||||||
}
|
}
|
||||||
hash_free(&cv8_state.file_hash);
|
hash_free(&cv8_state.file_hash);
|
||||||
|
|
||||||
@@ -398,8 +398,7 @@ static struct source_file *register_file(const char *filename)
|
|||||||
|
|
||||||
fullpath = nasm_realpath(filename);
|
fullpath = nasm_realpath(filename);
|
||||||
|
|
||||||
file = nasm_zalloc(sizeof(*file));
|
nasm_new(file);
|
||||||
|
|
||||||
file->filename = filename;
|
file->filename = filename;
|
||||||
file->fullname = fullpath;
|
file->fullname = fullpath;
|
||||||
file->fullnamelen = strlen(fullpath);
|
file->fullnamelen = strlen(fullpath);
|
||||||
|
Reference in New Issue
Block a user