Fix a few leaks

This commit is contained in:
Anton Kochkov 2017-07-29 19:55:40 +08:00
parent 0e4aa83d16
commit 8041b3c284
9 changed files with 12 additions and 1 deletions

View File

@ -879,7 +879,7 @@ int PE_(bin_pe_get_overlay)(struct PE_(r_bin_pe_obj_t)* bin, ut64* size) {
*size = bin->size - largest_offset - largest_size;
return largest_offset + largest_size;
}
free (sects);
return 0;
}
@ -1011,6 +1011,7 @@ static int bin_pe_init_metadata_hdr(struct PE_(r_bin_pe_obj_t)* bin) {
fail:
eprintf ("Warning: read (metadata header)\n");
free (metadata);
free (streams);
return 0;
}
@ -1523,6 +1524,7 @@ static String* Pe_r_bin_pe_parse_string(struct PE_(r_bin_pe_obj_t)* bin, PE_DWor
return NULL;
}
if (begAddr > bin->size || begAddr + sizeof(string->wLength) > bin->size) {
free_String (string);
return NULL;
}
if (r_buf_read_at (bin->b, *curAddr, (ut8*) &string->wLength, sizeof(string->wLength)) != sizeof(string->wLength)) {

View File

@ -438,6 +438,7 @@ static void dex_parse_debug_item(RBinFile *binfile, RBinDexObj *bin,
r_list_free (debug_positions);
free (params);
free (debug_locals);
free (emitted_debug_locals);
return;
}
// Emit what was previously there, if anything
@ -1245,6 +1246,7 @@ static const ut8 *parse_dex_class_method(RBinFile *binfile, RBinDexObj *bin,
if (*flag_name) {
RBinSymbol *sym = R_NEW0 (RBinSymbol);
if (!sym) {
R_FREE (flag_name);
return NULL;
}
sym->name = flag_name;

View File

@ -4142,6 +4142,7 @@ static void cmd_anal_calls(RCore *core, const char *input) {
}
r_cons_break_push (NULL, NULL);
if (!binfile || !r_list_length (ranges)) {
r_list_free (ranges);
const char *search_in = r_config_get (core->config, "search.in");
ranges = r_core_get_boundaries_prot (core, 0, search_in, &addr, &addr_end);
_anal_calls (core, addr, addr_end);

View File

@ -304,6 +304,7 @@ R_API void r_core_project_execute_cmds(RCore *core, const char *prjfile) {
bol = strtok (NULL, "\n");
}
free (data);
free (str);
}
/*** vvv thready ***/

View File

@ -1047,6 +1047,7 @@ R_API int r_core_visual_classes(RCore *core) {
r_cons_visual_flush ();
ch = r_cons_readchar ();
if (ch==-1 || ch==4) {
R_FREE (grep);
return false;
}

View File

@ -143,6 +143,7 @@ static proc_per_thread_t *get_proc_thread_content(int pid, int tid) {
proc_per_thread_t *t = R_NEW0 (proc_per_thread_t);
if (!t) {
free (buff);
return NULL;
}
{

View File

@ -75,6 +75,7 @@ R_API RIDStorage* r_id_storage_new(ut32 start_id, ut32 last_id) {
if ((start_id < 16) && (pool = r_id_pool_new (start_id, last_id))) {
storage = R_NEW0 (RIDStorage);
if (!storage) {
r_id_pool_free (pool);
return NULL;
}
storage->pool = pool;

View File

@ -1062,6 +1062,7 @@ R_API void r_print_hexdiff(RPrint *p, ut64 aa, const ut8 *_a, ut64 ba, const ut8
return;
}
if (!((b = M (_b, len)))) {
free (a);
return;
}
for (i = 0; i < len; i += 16) {

View File

@ -703,6 +703,7 @@ char* r_x509_crlentry_dump (RX509CRLEntry *crle, char* buffer, ut32 length, cons
pad, pad, id ? id->string : "Missing",
pad, pad, utc ? utc->string : "Missing");
r_asn1_free_string (id);
return r < 0 ? NULL : buffer + (ut32) r;
}