dwarf_loader: Call dwarf_cu__delete() when aborting the load
Addressing these covscan report entry: Error: GCC_ANALYZER_WARNING (CWE-401): dwarves-1.21/dwarf_loader.c:2645:40: warning[-Wanalyzer-malloc-leak]: leak of 'dcu' # 2643| filename); # 2644| if (cu == NULL || cu__set_common(cu, conf, mod, elf) != 0) # 2645|-> return DWARF_CB_ABORT; # 2646| # 2647| dcu = malloc(sizeof(struct dwarf_cu)); Error: RESOURCE_LEAK (CWE-772): dwarves-1.21/dwarf_loader.c:2647: alloc_fn: Storage is returned from allocation function "malloc". dwarves-1.21/dwarf_loader.c:2647: var_assign: Assigning: "dcu" = storage returned from "malloc(120UL)". dwarves-1.21/dwarf_loader.c:2663: leaked_storage: Variable "dcu" going out of scope leaks the storage it points to. # 2661| } # 2662| if (hashtags__bits < default_hbits) # 2663|-> return DWARF_CB_ABORT; # 2664| # 2665| dcu->cu = cu; Error: CLANG_WARNING: dwarves-1.21/dwarf_loader.c:2663:12: warning[unix.Malloc]: Potential leak of memory pointed to by 'dcu' # 2661| } # 2662| if (hashtags__bits < default_hbits) # 2663|-> return DWARF_CB_ABORT; # 2664| # 2665| dcu->cu = cu; Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
26bd4c4164
commit
32114e611a
|
@ -2696,6 +2696,7 @@ static int cus__merge_and_process_cu(struct cus *cus, struct conf_load *conf,
|
|||
return 0;
|
||||
|
||||
out_abort:
|
||||
dwarf_cu__delete(cu);
|
||||
cu__delete(cu);
|
||||
return DWARF_CB_ABORT;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue