From e0e170c3c58d0592d2d52657febe24670a161ca1 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Fri, 28 Aug 2015 18:29:31 +0200 Subject: [PATCH] Fix various clang-analyser issues --- binr/ragg2/ragg2.c | 1 + binr/rahash2/rahash2.c | 4 +++- libr/anal/esil.c | 2 +- libr/bin/format/objc/mach0_classes.c | 2 +- libr/bin/format/pe/pe.c | 2 ++ libr/bin/p/bin_elf.c | 2 +- libr/core/visual.c | 2 +- 7 files changed, 10 insertions(+), 5 deletions(-) diff --git a/binr/ragg2/ragg2.c b/binr/ragg2/ragg2.c index 6b3da1fdf4..0300c663b4 100644 --- a/binr/ragg2/ragg2.c +++ b/binr/ragg2/ragg2.c @@ -265,6 +265,7 @@ int main(int argc, char **argv) { sequence = strdup (optarg); break; default: + free (sequence); return 1; } } diff --git a/binr/rahash2/rahash2.c b/binr/rahash2/rahash2.c index 6c1ff50cad..9298c4ef10 100644 --- a/binr/rahash2/rahash2.c +++ b/binr/rahash2/rahash2.c @@ -272,7 +272,9 @@ int main(int argc, char **argv) { while ((c = getopt (argc, argv, "jdDrvea:i:S:s:x:b:nBhf:t:kLq")) != -1) { switch (c) { case 'q': quiet = 1; break; - case 'i': iterations = atoi (optarg); + case 'i': + if (!optarg) return 1; + iterations = atoi (optarg); if (iterations<0) { eprintf ("error: -i argument must be positive\n"); return 1; diff --git a/libr/anal/esil.c b/libr/anal/esil.c index fe73e1ff14..578d0b062a 100644 --- a/libr/anal/esil.c +++ b/libr/anal/esil.c @@ -1179,7 +1179,7 @@ static int esil_deceq (RAnalEsil *esil) { static int esil_poke1(RAnalEsil *esil) { int ret = 0; ut64 num, addr; - ut8 num1; + ut8 num1 = 0; char *dst = r_anal_esil_pop (esil); char *src = r_anal_esil_pop (esil); if (src && r_anal_esil_get_parm (esil, src, &num)) { diff --git a/libr/bin/format/objc/mach0_classes.c b/libr/bin/format/objc/mach0_classes.c index 877d9d0c14..788e5c447d 100644 --- a/libr/bin/format/objc/mach0_classes.c +++ b/libr/bin/format/objc/mach0_classes.c @@ -178,7 +178,7 @@ static void copy_sym_name_with_namespace (char *class_name, size_t len = 0; char *tmp = 0; - len = strlen (class_name); + len = class_name ? strlen (class_name) : 0; memcpy (sym->classname, class_name, (len < R_BIN_SIZEOF_STRINGS) ? len : R_BIN_SIZEOF_STRINGS); diff --git a/libr/bin/format/pe/pe.c b/libr/bin/format/pe/pe.c index cf0c3b1bf1..aab20cbf3e 100644 --- a/libr/bin/format/pe/pe.c +++ b/libr/bin/format/pe/pe.c @@ -236,6 +236,8 @@ static int bin_pe_parse_imports(struct PE_(r_bin_pe_obj_t)* bin, struct r_bin_pe snprintf (import_name, PE_NAME_LENGTH, "%s_%s", dll_name, name); } if (!(*importp = realloc (*importp, (*nimp + 1) * sizeof(struct r_bin_pe_import_t)))) { + free (symdllname); + free (sdb_module); r_sys_perror ("realloc (import)"); return R_FALSE; } diff --git a/libr/bin/p/bin_elf.c b/libr/bin/p/bin_elf.c index 44b7cedf3b..53b6964878 100644 --- a/libr/bin/p/bin_elf.c +++ b/libr/bin/p/bin_elf.c @@ -516,7 +516,7 @@ static RBinInfo* info(RBinFile *arch) { ret->lang = "c"; if (arch->file) ret->file = strdup (arch->file); - else *ret->file = 0; + else ret->file = '\0'; if ((str = Elf_(r_bin_elf_get_rpath)(arch->o->bin_obj))) { ret->rpath = strdup (str); free (str); diff --git a/libr/core/visual.c b/libr/core/visual.c index d6ef8778bf..078314f223 100644 --- a/libr/core/visual.c +++ b/libr/core/visual.c @@ -1779,7 +1779,7 @@ R_API int r_core_visual(RCore *core, const char *input) { color = r_config_get_i (core->config, "scr.color"); if (color) flags |= R_PRINT_FLAGS_COLOR; debug = r_config_get_i (core->config, "cfg.debug"); - flags = R_PRINT_FLAGS_ADDRMOD | R_PRINT_FLAGS_HEADER; + flags |= R_PRINT_FLAGS_ADDRMOD | R_PRINT_FLAGS_HEADER; r_print_set_flags (core->print, core->print->flags); scrseek = r_num_math (core->num, r_config_get (core->config, "scr.seek"));