@@ -1220,9 +1220,13 @@ static int init_die(RzBinDwarfDie *die, ut64 abbr_code, ut64 attr_count) {
1220
1220
if (!die ) {
1221
1221
return -1 ;
1222
1222
}
1223
- die -> attr_values = calloc (sizeof (RzBinDwarfAttrValue ), attr_count );
1224
- if (!die -> attr_values ) {
1225
- return -1 ;
1223
+ if (attr_count ) {
1224
+ die -> attr_values = calloc (sizeof (RzBinDwarfAttrValue ), attr_count );
1225
+ if (!die -> attr_values ) {
1226
+ return -1 ;
1227
+ }
1228
+ } else {
1229
+ die -> attr_values = NULL ;
1226
1230
}
1227
1231
die -> abbrev_code = abbr_code ;
1228
1232
die -> capacity = attr_count ;
@@ -1726,25 +1730,27 @@ static const ut8 *parse_die(const ut8 *buf, const ut8 *buf_end, RzBinDwarfDebugI
1726
1730
size_t i ;
1727
1731
const char * comp_dir = NULL ;
1728
1732
ut64 line_info_offset = UT64_MAX ;
1729
- for (i = 0 ; i < abbrev -> count - 1 ; i ++ ) {
1730
- memset (& die -> attr_values [i ], 0 , sizeof (die -> attr_values [i ]));
1733
+ if (abbrev -> count ) {
1734
+ for (i = 0 ; i < abbrev -> count - 1 ; i ++ ) {
1735
+ memset (& die -> attr_values [i ], 0 , sizeof (die -> attr_values [i ]));
1731
1736
1732
- buf = parse_attr_value (buf , buf_end - buf , & abbrev -> defs [i ],
1733
- & die -> attr_values [i ], hdr , debug_str , debug_str_len , big_endian );
1737
+ buf = parse_attr_value (buf , buf_end - buf , & abbrev -> defs [i ],
1738
+ & die -> attr_values [i ], hdr , debug_str , debug_str_len , big_endian );
1734
1739
1735
- RzBinDwarfAttrValue * attribute = & die -> attr_values [i ];
1740
+ RzBinDwarfAttrValue * attribute = & die -> attr_values [i ];
1736
1741
1737
- if (attribute -> attr_name == DW_AT_comp_dir && (attribute -> attr_form == DW_FORM_strp || attribute -> attr_form == DW_FORM_string ) && attribute -> string .content ) {
1738
- comp_dir = attribute -> string .content ;
1739
- }
1740
- if (attribute -> attr_name == DW_AT_stmt_list ) {
1741
- if (attribute -> kind == DW_AT_KIND_CONSTANT ) {
1742
- line_info_offset = attribute -> uconstant ;
1743
- } else if (attribute -> kind == DW_AT_KIND_REFERENCE ) {
1744
- line_info_offset = attribute -> reference ;
1742
+ if (attribute -> attr_name == DW_AT_comp_dir && (attribute -> attr_form == DW_FORM_strp || attribute -> attr_form == DW_FORM_string ) && attribute -> string .content ) {
1743
+ comp_dir = attribute -> string .content ;
1744
+ }
1745
+ if (attribute -> attr_name == DW_AT_stmt_list ) {
1746
+ if (attribute -> kind == DW_AT_KIND_CONSTANT ) {
1747
+ line_info_offset = attribute -> uconstant ;
1748
+ } else if (attribute -> kind == DW_AT_KIND_REFERENCE ) {
1749
+ line_info_offset = attribute -> reference ;
1750
+ }
1745
1751
}
1752
+ die -> count ++ ;
1746
1753
}
1747
- die -> count ++ ;
1748
1754
}
1749
1755
1750
1756
// If this is a compilation unit dir attribute, we want to cache it so the line info parsing
0 commit comments