diff --git a/libr/anal/p/anal_java.c b/libr/anal/p/anal_java.c index 5dd731d9e3..6b5deca86d 100644 --- a/libr/anal/p/anal_java.c +++ b/libr/anal/p/anal_java.c @@ -208,7 +208,7 @@ static int java_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len return sz; } IFDBG { - R_LOG_DEBUG ("Extracting op from buffer (%d byte(s)) @ 0x%04x\n", len, addr); + R_LOG_DEBUG ("Extracting op from buffer (%d byte(s)) @ 0x%04x\n", (int)len, (ut32)addr); R_LOG_DEBUG ("Parsing op: (0x%02x) %s.\n", op_byte, JAVA_OPS[op_byte].name); } op->addr = addr; diff --git a/libr/asm/arch/8051/8051_ass.c b/libr/asm/arch/8051/8051_ass.c index 10f94c7cea..fb623ea7e7 100644 --- a/libr/asm/arch/8051/8051_ass.c +++ b/libr/asm/arch/8051/8051_ass.c @@ -888,10 +888,13 @@ static bool mnem_jbc(char const*const*arg, ut16 pc, ut8**out) { } ut16 jmp_addr; - to_address (arg[1], &jmp_addr); + if (!to_address (arg[1], &jmp_addr)) { + R_LOG_DEBUG ("error during the assembly: address %x not found", jmp_addr); + return false; + } if (!relative_address (pc + 1, jmp_addr, (*out) + 2)) { - eprintf ("error during the assembly: address %x not found\n", jmp_addr); + R_LOG_DEBUG ("error during the assembly: address %x not found", jmp_addr); return false; } diff --git a/libr/asm/p/cs_mnemonics.c b/libr/asm/p/cs_mnemonics.c index 6bdbd86d7e..2963b90177 100644 --- a/libr/asm/p/cs_mnemonics.c +++ b/libr/asm/p/cs_mnemonics.c @@ -14,7 +14,7 @@ static char *mnemonics(RAsm *a, int id, bool json) { pj = pj_new (); pj_a (pj); } else { - r_strbuf_new (""); + buf = r_strbuf_new (""); } for (i = 1; ; i++) { const char *op = cs_insn_name (cd, i); diff --git a/libr/bin/format/mach0/coresymbolication.c b/libr/bin/format/mach0/coresymbolication.c index 949afc42cc..832f8ce14a 100644 --- a/libr/bin/format/mach0/coresymbolication.c +++ b/libr/bin/format/mach0/coresymbolication.c @@ -362,10 +362,6 @@ RCoreSymCacheElement *r_coresym_cache_element_new(RBinFile *bf, RBuffer *buf, ut continue; } string_origin = relative_to_strings? b + start_of_strings : cursor; - if (!string_origin) { - cursor += R_CS_EL_SIZE_LSYM; - continue; - } lsym->flc.file = str_dup_safe (b, string_origin + file_name_off, end); if (!lsym->flc.file) { cursor += R_CS_EL_SIZE_LSYM; diff --git a/libr/core/cmd_write.c b/libr/core/cmd_write.c index 16bb25625c..591e12d1ba 100644 --- a/libr/core/cmd_write.c +++ b/libr/core/cmd_write.c @@ -1654,6 +1654,7 @@ static int cmd_ww(void *data, const char *input) { char *str = ostr; int len = r_str_unescape (str); if (len < 1) { + free (ostr); return 0; } len++; @@ -1663,10 +1664,11 @@ static int cmd_ww(void *data, const char *input) { if (tmp) { int i; for (i = 0; i < len; i++) { - if (i % 2) + if (i % 2) { tmp[i] = 0; - else + } else { tmp[i] = str[i >> 1]; + } } str = tmp; if (core->io->desc) { @@ -1784,7 +1786,7 @@ static int cmd_wa(void *data, const char *input) { ut64 at = core->offset; repeat: if (!r_anal_op (core->anal, &analop, at, core->block + delta, core->blocksize - delta, R_ANAL_OP_MASK_BASIC)) { - eprintf ("Invalid instruction?\n"); + R_LOG_DEBUG ("Invalid instruction?"); break; } if (delta < acode->len) { @@ -1800,11 +1802,13 @@ repeat: } else if (input[0] == 'i') { // "wai" RAnalOp analop; if (!r_anal_op (core->anal, &analop, core->offset, core->block, core->blocksize, R_ANAL_OP_MASK_BASIC)) { - eprintf ("Invalid instruction?\n"); + R_LOG_DEBUG ("Invalid instruction?"); + r_anal_op_fini (&analop); + r_asm_code_free (acode); break; } if (analop.size < acode->len) { - eprintf ("Doesnt fit\n"); + R_LOG_DEBUG ("Doesnt fit"); r_anal_op_fini (&analop); r_asm_code_free (acode); break; diff --git a/libr/core/rtr.c b/libr/core/rtr.c index 9f4a1ed03b..7ff453007b 100644 --- a/libr/core/rtr.c +++ b/libr/core/rtr.c @@ -110,7 +110,7 @@ static void rtr_textlog_chat(RCore *core, TextLog T) { char buf[1024]; int lastmsg = 0; const char *me = r_config_get (core->config, "cfg.user"); - char *ret, msg[1024]; + char *ret, msg[1024] = {0}; eprintf ("Type '/help' for commands and ^D to quit:\n"); char *oldprompt = strdup (r_line_singleton ()->prompt); diff --git a/libr/debug/p/native/linux/linux_debug.c b/libr/debug/p/native/linux/linux_debug.c index 3ff6436f5d..48c4163365 100644 --- a/libr/debug/p/native/linux/linux_debug.c +++ b/libr/debug/p/native/linux/linux_debug.c @@ -1361,7 +1361,7 @@ RList *linux_desc_list(int pid) { type = '-'; } } - // Read permissions + // Read permissions // TOCTOU if (lstat (fn, &st) != -1) { if (st.st_mode & S_IRUSR) { perm |= R_PERM_R; @@ -1385,10 +1385,10 @@ RList *linux_desc_list(int pid) { free (fn); return NULL; } - free (fn); fdinfo[sizeof (fdinfo) - 1] = '\0'; close (f); } + free (fn); /* First line of fdinfo is "pos: [offset]" */ ut64 offset = (int) r_num_math (NULL, r_str_trim_head_ro (fdinfo + 4)); RDebugDesc *desc = r_debug_desc_new (atoi (de->d_name), buf, perm, type, offset); diff --git a/libr/debug/p/native/xnu/xnu_debug.c b/libr/debug/p/native/xnu/xnu_debug.c index 40c02af2f6..4934eed018 100644 --- a/libr/debug/p/native/xnu/xnu_debug.c +++ b/libr/debug/p/native/xnu/xnu_debug.c @@ -842,7 +842,6 @@ static int xnu_write_mem_maps_to_buffer(RBuffer *buffer, RList *mem_maps, int st // xfer_foffset += xfer_size; } } - hoffset += segment_command_sz; foffset += curr_map->size; vmoffset += curr_map->size; diff --git a/libr/main/rasm2.c b/libr/main/rasm2.c index bdf41cfd8a..fb8f4a5a3a 100644 --- a/libr/main/rasm2.c +++ b/libr/main/rasm2.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2009-2021 - pancake, nibble, maijin */ +/* radare - LGPL - Copyright 2009-2022 - pancake, nibble, maijin */ #include #include @@ -34,10 +34,9 @@ static RAsmState *__as_new(void) { if (as) { as->l = r_lib_new (NULL, NULL); as->a = r_asm_new (); - if (as->a) { - as->a->num = r_num_new (NULL, NULL, NULL); - } as->anal = r_anal_new (); + r_unref (as->anal->config); + as->a->num = r_num_new (NULL, NULL, NULL); as->anal->config = r_ref (as->a->config); r_anal_bind (as->anal, &as->a->analb); __load_plugins (as);