Skip to content

Commit 7cff033

Browse files
committed
Changes to be committed:
Coverity scan CID 531838. Mem leak. Free the block h points to here too. modified: src/lib/libdwarf/dwarf_dsc.c
1 parent fa68586 commit 7cff033

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/lib/libdwarf/dwarf_dsc.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ int dwarf_discr_list(Dwarf_Debug dbg,
212212
ary = (struct Dwarf_Dsc_Entry_s *)calloc(arraycount,
213213
sizeof(struct Dwarf_Dsc_Entry_s));
214214
if (!ary) {
215+
/* Coverity scan CID 531838. Mem leak.
216+
Free the block h points to here too. */
217+
free(h->dsh_block);
218+
h->dsh_block = 0;
219+
h->dsh_block_len = 0;
220+
dscblockp = 0;
215221
dwarf_dealloc(dbg,h,DW_DLA_DSC_HEAD);
216222
_dwarf_error(dbg, error, DW_DLE_ALLOC_FAIL);
217223
return DW_DLV_ERROR;
@@ -220,7 +226,6 @@ int dwarf_discr_list(Dwarf_Debug dbg,
220226
h->dsh_array = ary;
221227
h->dsh_set_unsigned = 0;
222228
h->dsh_set_signed = 0;
223-
224229
*dsc_head_out = h;
225230
*dsc_array_length_out = arraycount;
226231
return DW_DLV_OK;

0 commit comments

Comments
 (0)