Couple of leak fixes

This commit is contained in:
David CARLIER 2018-11-15 15:34:11 +00:00 committed by radare
parent 8f2f9de1f3
commit 3d830a3832
2 changed files with 17 additions and 2 deletions

View File

@ -762,7 +762,9 @@ int main(int argc, char **argv) {
case 'o': output = optarg; break;
case 'p': va = false; break;
case 'r': rad = true; break;
case 'v': return blob_version ("rabin2");
case 'v':
r_core_fini (&core);
return blob_version ("rabin2");
case 'L':
set_action (R_BIN_REQ_LISTPLUGINS);
break;
@ -803,6 +805,7 @@ int main(int argc, char **argv) {
plugin_name = argv[optind];
}
rabin_list_plugins (plugin_name);
r_core_fini (&core);
return 0;
}
@ -810,6 +813,7 @@ int main(int argc, char **argv) {
char *res = NULL;
int type;
if ((argc - optind) < 2) {
r_core_fini (&core);
return rabin_show_help (0);
}
type = r_bin_demangle_type (do_demangle);
@ -823,6 +827,7 @@ int main(int argc, char **argv) {
res = demangleAs (type);
if (!res) {
eprintf ("Unknown lang to demangle. Use: cxx, java, objc, swift\n");
r_core_fini (&core);
return 1;
}
if (res && *res) {
@ -838,6 +843,7 @@ int main(int argc, char **argv) {
if (res && *res) {
printf ("%s\n", res);
free(res);
r_core_fini (&core);
return 0;
} else {
printf ("%s\n", file);
@ -845,6 +851,7 @@ int main(int argc, char **argv) {
}
free (res);
//eprintf ("%s\n", file);
r_core_fini (&core);
return 1;
}
file = argv[optind];
@ -925,6 +932,7 @@ int main(int argc, char **argv) {
if (!file) {
eprintf ("Missing file.\n");
r_core_fini (&core);
return 1;
}
@ -932,6 +940,7 @@ int main(int argc, char **argv) {
#if __UNIX__
int child = r_sys_fork ();
if (child == -1) {
r_core_fini (&core);
return 1;
}
if (child == 0) {
@ -942,9 +951,11 @@ int main(int argc, char **argv) {
if (addr) {
eprintf ("%s is loaded at 0x%"PFMT64x"\n", file, (ut64)(size_t)(addr));
r_lib_dl_close (addr);
r_core_fini (&core);
return 0;
}
eprintf ("Cannot open the '%s' library\n", file);
r_core_fini (&core);
return 0;
}
if (action & R_BIN_REQ_PACKAGE) {
@ -955,6 +966,7 @@ int main(int argc, char **argv) {
if (optind + 3 > argc) {
eprintf ("Usage: rabin2 -X [fat|zip] foo.zip a b c\n");
r_core_fini (&core);
return 1;
}
eprintf ("FMT %s\n", format);

View File

@ -500,7 +500,9 @@ int main(int argc, char **argv) {
if (show_raw || show_hex || show_execute) {
if (show_execute) {
return r_egg_run (egg);
int r = r_egg_run (egg);
r_egg_free (egg);
return r;
}
b = r_egg_get_bin (egg);
if (show_raw) {
@ -545,6 +547,7 @@ int main(int argc, char **argv) {
eprintf ("unknown executable format (%s)\n", format);
goto fail;
}
r_print_free (p);
}
}
r_egg_free (egg);