Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion librz/bin/format/mach0/mach0.c
Original file line number Diff line number Diff line change
Expand Up @@ -1872,6 +1872,9 @@ void *MACH0_(mach0_free)(struct MACH0_(obj_t) * mo) {
rz_skiplist_free(mo->relocs);
rz_hash_free(mo->hash);
rz_buf_free(mo->b);
rz_buf_free(mo->buf_patched);
rz_pvector_free(mo->sections_cache);
sdb_free(mo->kv);
free(mo);
return NULL;
}
Expand Down Expand Up @@ -2449,7 +2452,7 @@ static int walk_exports(struct MACH0_(obj_t) * bin, ExportsIterator iterator, vo
goto beach;
}
if (state->i == child_count) {
rz_list_pop(states);
free(rz_list_pop(states));
continue;
}
if (!state->next_child) {
Expand Down
1 change: 1 addition & 0 deletions librz/bin/p/bin_mach0.inc
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ static void process_constructors(RzBinFile *bf, RzPVector /*<RzBinAddr *>*/ *ret
free(buf);
}
}
rz_pvector_free(secs);
}

static RzPVector /*<RzBinAddr *>*/ *mach0_entries(RzBinFile *bf) {
Expand Down
2 changes: 1 addition & 1 deletion librz/core/cmd/cmd_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,7 @@ RZ_IPI void rz_core_debug_bp_add(RzCore *core, ut64 addr, const char *arg_perm,
rz_bp_item_set_name(bpi, name);
free(name);
} else {
bpi->name = rz_str_dup(f->name);
rz_bp_item_set_name(bpi, f->name);
}
} else {
char *name = rz_str_newf("0x%08" PFMT64x, addr);
Expand Down
8 changes: 8 additions & 0 deletions librz/core/cmeta.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,13 @@ static bool meta_string_guess_add(RzCore *core, ut64 addr, size_t limit, char **
return false;
}
*ds = rz_list_first_val(str_list);
RzListIter *it;
RzDetectedString *s;
rz_list_foreach (str_list, it, s) {
if (s != *ds) {
rz_detected_string_free(s);
}
}
rz_list_free(str_list);
rz_str_ncpy(name, (*ds)->string, limit);
name[limit] = '\0';
Expand Down Expand Up @@ -434,6 +441,7 @@ RZ_API bool rz_core_meta_string_add(RzCore *core, ut64 addr, ut64 size, RzStrEnc
}
encoding = ds->encoding;
n = ds->size;
rz_detected_string_free(ds);
}
if (!name) {
result = rz_meta_set_with_subtype(core->analysis, RZ_META_TYPE_STRING, encoding, addr, n, guessname);
Expand Down
10 changes: 10 additions & 0 deletions librz/type/parser/types_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,9 @@ int parse_typedef_node(CParserState *state, TSNode node, const char *text, Parse
}
// If parsing successfull completed - we store the state
if (typedef_pair) {
// c_parser_new_typedef() may seed btype->type with a placeholder
// identifier; release it before overwriting with the resolved type.
rz_type_free(typedef_pair->btype->type);
typedef_pair->btype->type = rz_type_clone(type_pair->type);
parser_debug(state, "storing typedef \"%s\" -> \"%s\"\n", typedef_name, base_type_name);
c_parser_base_type_store(state, typedef_name, typedef_pair);
Expand All @@ -1222,9 +1225,16 @@ int parse_typedef_node(CParserState *state, TSNode node, const char *text, Parse
}
// FIXME: We should return multiple types at once
*tpair = typedef_pair;
// c_parser_new_typedef()/c_parser_base_type_store() copy the name, so the
// declarator string extracted above can be released each iteration.
free(typedef_name);
typedef_declarator = ts_node_next_named_sibling(typedef_declarator);
} while (!ts_node_is_null(typedef_declarator) && is_type_declarator(ts_node_type(typedef_declarator)));

// The underlying type pair was only needed to derive the typedef target; its
// RzBaseType is owned by the parser state, so drop the wrapper and its RzType.
rz_type_free(type_pair->type);
free(type_pair);
return 0;
}

Expand Down
Loading