Fix more clang-analyzer warnings (#12427)

This commit is contained in:
dav1901 2018-12-10 15:41:38 +02:00 committed by radare
parent 2ebd956fdd
commit d067c16266
8 changed files with 10 additions and 12 deletions

View File

@ -50,8 +50,6 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
r_asm_op_set_asm (op, "invalid");
op->size = 4;
goto beach;
} else {
ret = 4;
}
if (insn->size < 1) {
goto beach;

View File

@ -2253,7 +2253,6 @@ static int oppush(RAsm *a, ut8 *data, const Opcode *op) {
} else if (op->operands[0].type & OT_MEMORY) {
data[l++] = 0xff;
offset = op->operands[0].offset * op->operands[0].offset_sign;
mod = 0;
if (offset != 0 || op->operands[0].regs[0] == X86R_EBP) {
mod = 1;
if (offset >= 128 || offset < -128) {

View File

@ -873,6 +873,7 @@ static RList *strings(RBinFile *bf) {
ptr->string[len] = 0;
if ((ptr->string[0] == 'L' && strchr (ptr->string, '/')) || !strncmp (ptr->string, "[L", 2)) {
free (ptr->string);
free (ptr);
continue;
}
ptr->vaddr = ptr->paddr = bin->strings[i];

View File

@ -325,6 +325,7 @@ R_API char *r_cons_hud_path(const char *path, int dir) {
if (ret) {
tmp = r_str_append (tmp, "/");
tmp = r_str_append (tmp, ret);
free (ret);
ret = r_file_abspath (tmp);
free (tmp);
tmp = ret;

View File

@ -5712,7 +5712,7 @@ R_API int r_core_print_disasm_all(RCore *core, ut64 addr, int l, int len, int mo
}
ret = r_asm_disassemble (core->assembler, &asmop, buf + i, l - i);
if (ret < 1) {
ret = err = 1;
err = 1;
switch (mode) {
case 'j':
case '=':
@ -5864,11 +5864,10 @@ R_API int r_core_disasm_pdi(RCore *core, int nb_opcodes, int nb_bytes, int fmt)
int len = (nb_opcodes + nb_bytes) * 5;
if (core->fixedblock) {
len = core->blocksize;
} else {
if (len > core->blocksize) {
r_core_block_size (core, len);
r_core_block_read (core);
}
}
if (len > core->blocksize) {
r_core_block_size (core, len);
r_core_block_read (core);
}
r_cons_break_push (NULL, NULL);

View File

@ -125,7 +125,6 @@ R_API int r_diff_buffers_static(RDiff *d, const ut8 *a, int la, const ut8 *b, in
.b_off = d->off_b+i-hit, .b_buf = b+i-hit, .b_len = R_MIN (hit, rb)
};
d->callback (d, d->user, &o);
hit = 0;
}
return 0;
}

View File

@ -2324,7 +2324,7 @@ R_API int r_print_format_length(const char *fmt) {
const char *argend = arg+strlen (fmt);
char namefmt[8];
int viewflags = 0;
nargs = endian = i = j = 0;
endian = i = j = 0;
while (*arg && IS_WHITECHAR (*arg)) {
arg++;

View File

@ -690,10 +690,11 @@ R_API int r_sys_cmd(const char *str) {
}
R_API char *r_sys_cmd_str(const char *cmd, const char *input, int *len) {
char *output;
char *output = NULL;
if (r_sys_cmd_str_full (cmd, input, &output, len, NULL)) {
return output;
}
free (output);
return NULL;
}