Skip to content

Commit

Permalink
libdwarf: Fix a possible memory leak in dwarf_add_AT_location_expr().
Browse files Browse the repository at this point in the history
CID:		1193364
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
  • Loading branch information
markjdb committed Feb 4, 2020
1 parent 15e0fa1 commit 0fa4fd5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion contrib/elftoolchain/libdwarf/dwarf_pro_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ dwarf_add_AT_location_expr(Dwarf_P_Debug dbg, Dwarf_P_Die die, Dwarf_Half attr,
at->at_attrib = attr;
at->at_expr = loc_expr;

if (_dwarf_expr_into_block(loc_expr, error) != DW_DLE_NONE)
if (_dwarf_expr_into_block(loc_expr, error) != DW_DLE_NONE) {
free(at);
return (DW_DLV_BADADDR);
}
at->u[0].u64 = loc_expr->pe_length;
at->u[1].u8p = loc_expr->pe_block;
if (loc_expr->pe_length <= UCHAR_MAX)
Expand Down

0 comments on commit 0fa4fd5

Please sign in to comment.