Skip to content

Commit ba02b9f

Browse files
authored
Fix dealloc invalid dwarf_formstring
1 parent 88d7564 commit ba02b9f

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/symbols/dwarf/dwarf.hpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,9 @@ namespace libdwarf {
149149
auto attwrapper = raii_wrap(attr, [] (Dwarf_Attribute attr) { dwarf_dealloc_attribute(attr); });
150150
char* raw_str;
151151
VERIFY(wrap(dwarf_formstring, attr, &raw_str) == DW_DLV_OK);
152-
auto strwrapper = raii_wrap(raw_str, [this] (char* str) { dwarf_dealloc(dbg, str, DW_DLA_STRING); });
153-
std::string str = raw_str;
154-
return str;
155-
} else {
156-
return nullopt;
152+
return std::string(raw_str);
157153
}
154+
return nullopt;
158155
}
159156

160157
optional<Dwarf_Unsigned> get_unsigned_attribute(Dwarf_Half attr_num) const {
@@ -166,9 +163,8 @@ namespace libdwarf {
166163
Dwarf_Unsigned val;
167164
VERIFY(wrap(dwarf_formudata, attr, &val) == DW_DLV_OK);
168165
return val;
169-
} else {
170-
return nullopt;
171166
}
167+
return nullopt;
172168
}
173169

174170
bool has_attr(Dwarf_Half attr_num) const {

0 commit comments

Comments
 (0)