From 3d830a3832decbcca18ba65f63ef6144ac597d77 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Thu, 15 Nov 2018 15:34:11 +0000 Subject: [PATCH] Couple of leak fixes --- binr/rabin2/rabin2.c | 14 +++++++++++++- binr/ragg2/ragg2.c | 5 ++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/binr/rabin2/rabin2.c b/binr/rabin2/rabin2.c index f85e0295aa..114bbaac67 100644 --- a/binr/rabin2/rabin2.c +++ b/binr/rabin2/rabin2.c @@ -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); diff --git a/binr/ragg2/ragg2.c b/binr/ragg2/ragg2.c index 7fbd8d436c..b36f602e5a 100644 --- a/binr/ragg2/ragg2.c +++ b/binr/ragg2/ragg2.c @@ -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);