From ee211d9cb9cab042a9b50e8e96799875f99e8018 Mon Sep 17 00:00:00 2001 From: Irina Dudina Date: Sat, 18 Jul 2020 12:37:55 +0300 Subject: [PATCH] codeview: fix use after free in cleanup Reported by Svace static analyzer. Signed-off-by: Irina Dudina --- output/codeview.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/output/codeview.c b/output/codeview.c index f424bec66..d5c4ebf75 100644 --- a/output/codeview.c +++ b/output/codeview.c @@ -306,7 +306,7 @@ static void build_type_table(struct coff_Section *const sect); static void cv8_cleanup(void) { struct cv8_symbol *sym; - struct source_file *file; + struct source_file *file, *filetmp; struct coff_Section *symbol_sect = coff_sects[cv8_state.symbol_sect]; struct coff_Section *type_sect = coff_sects[cv8_state.type_sect]; @@ -317,7 +317,7 @@ static void cv8_cleanup(void) build_symbol_table(symbol_sect); build_type_table(type_sect); - list_for_each(file, cv8_state.source_files) { + list_for_each_safe(file, filetmp, cv8_state.source_files) { nasm_free(file->fullname); saa_free(file->lines); free(file);