From a193e54eac18ae78653da0913e7d742d0182993c Mon Sep 17 00:00:00 2001 From: jvoisin Date: Tue, 17 Feb 2015 00:34:51 +0100 Subject: [PATCH] Coverifix --- libr/cons/less.c | 1 + libr/core/cmd_project.c | 16 +++++++--------- libr/core/vmenus.c | 4 ++++ libr/util/print.c | 5 +++-- shlr/java/class.c | 7 +++---- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/libr/cons/less.c b/libr/cons/less.c index 5b0fe3b781..762b42682a 100644 --- a/libr/cons/less.c +++ b/libr/cons/less.c @@ -141,6 +141,7 @@ R_API void r_cons_less_str(const char *str) { if(rx) r_regex_free(rx); free (lines); free (p); + free (ms); r_cons_set_raw (R_FALSE); r_cons_show_cursor (R_TRUE); } diff --git a/libr/core/cmd_project.c b/libr/core/cmd_project.c index 8a0299d10c..3ec7cca480 100644 --- a/libr/core/cmd_project.c +++ b/libr/core/cmd_project.c @@ -57,21 +57,19 @@ static int cmd_project(void *data, const char *input) { nl = strchr (ptr, '\n'); if (nl) { *nl++ = 0; - if (strstr (ptr, input+2)) { - del ++; - } else { + if (strstr (ptr, input+2)) + del++; + else fprintf (fd, "%s\n", ptr); - } } } - free (data); } - fclose (fd); - free (str); - if (del>0) { + if (del>0) eprintf ("Deleted %d lines\n", del); - } } + free (data); + fclose (fd); + free (str); } break; case ' ': diff --git a/libr/core/vmenus.c b/libr/core/vmenus.c index 0981cd8967..6acf38c8d2 100644 --- a/libr/core/vmenus.c +++ b/libr/core/vmenus.c @@ -653,6 +653,7 @@ R_API void r_core_visual_mounts (RCore *core) { i++; } r_list_free (list); + list = NULL; } else r_cons_printf ("Cannot read partition\n"); } else if (mode == 1) { r_cons_printf ("Types:\n\n"); @@ -686,6 +687,7 @@ R_API void r_core_visual_mounts (RCore *core) { } r_cons_printf ("\n"); r_list_free (list); + list = NULL; } else r_cons_printf ("Cannot open '%s' directory\n", root); } else r_cons_printf ("Root undefined\n"); } @@ -698,6 +700,7 @@ R_API void r_core_visual_mounts (RCore *core) { if (file && file->type != 'd') r_core_cmdf (core, "px @ 0x%"PFMT64x"!64", file->off); r_list_free (list); + list = NULL; *str='\0'; } r_cons_flush (); @@ -753,6 +756,7 @@ R_API void r_core_visual_mounts (RCore *core) { r_cons_any_key (); } r_list_free (list); + list = NULL; } else if (mode == 2){ r_str_chop_path (path); strncat (path, "/", sizeof (path)-strlen (path)-1); diff --git a/libr/util/print.c b/libr/util/print.c index d015e09ebd..094bfd84d5 100644 --- a/libr/util/print.c +++ b/libr/util/print.c @@ -87,7 +87,7 @@ R_API char *r_print_stereogram(const char *bump, int w, int h) { char *out; if (w<1 || h<1) return NULL; - size = w * h*2; + size = w * (ut64)h * 2; if (size>UT32_MAX) { return NULL; } @@ -123,12 +123,13 @@ R_API char *r_print_stereogram_bytes(const ut8 *buf, int len) { } bump[bumpi] = 0; ret = r_print_stereogram (bump, cols, rows); + free (bump); return ret; } R_API void r_print_stereogram_print(RPrint *p, const char *ret) { int i; - int use_color = p? (p->flags & R_PRINT_FLAGS_COLOR): 0; + const int use_color = p->flags & R_PRINT_FLAGS_COLOR; if (!ret) return; if (use_color) { for (i=0; ret[i]; i++) { diff --git a/shlr/java/class.c b/shlr/java/class.c index 4ba9b8b664..60bbafa193 100644 --- a/shlr/java/class.c +++ b/shlr/java/class.c @@ -698,10 +698,9 @@ R_API DsoJsonObj * r_bin_java_get_import_json_definitions(RBinJavaObj *bin) { RListIter *iter = NULL; char *new_str; - if (!bin || !the_list) + if (!bin || !(the_list = r_bin_java_get_lib_names (bin))) return json_list; - the_list = r_bin_java_get_lib_names (bin); r_list_foreach ( the_list, iter, new_str) { char *tmp = new_str; //eprintf ("Processing string: %s\n", new_str); @@ -779,10 +778,10 @@ R_API DsoJsonObj * r_bin_java_get_interface_json_definitions(RBinJavaObj *bin) { DsoJsonObj *json_list = dso_json_list_new (); RListIter *iter = NULL; char *new_str; - if (!bin || !the_list) + + if (!bin || !(the_list = r_bin_java_get_interface_names (bin))) return json_list; - the_list = r_bin_java_get_interface_names (bin); r_list_foreach ( the_list, iter, new_str) { char *tmp = new_str; //eprintf ("Processing string: %s\n", new_str);