Once again, clang-analyzer strikes!

This commit is contained in:
jvoisin 2015-09-04 15:12:42 +02:00
parent cff606d99f
commit fbe8b6d938
12 changed files with 28 additions and 23 deletions

View File

@ -362,7 +362,7 @@ static struct r_i8015_reg *i8051_reg_find(const char *name) {
static int i8051_reg_get_offset(RAnalEsil *esil, struct r_i8015_reg *ri) {
ut8 offset = ri->offset;
if (ri->banked) {
ut64 psw;
ut64 psw = NULL;
i8051_hook_reg_read(esil, "psw", &psw);
offset += psw & 0x18;
}

View File

@ -36,7 +36,7 @@
static char *getarg(csh handle, cs_insn *insn, int n, int set, char *setop) {
char buf[64];
char *setarg = setop? setop : "";
cs_x86_op op = {0};
cs_x86_op op;
if (!insn->detail)
return NULL;
buf[0] = 0;

View File

@ -83,8 +83,11 @@ static RList *strings(RBinFile *arch) {
static RBinInfo* info(RBinFile *arch) {
ArtObj *ao = arch->o->bin_obj;
RBinInfo *ret = R_NEW0 (RBinInfo);
if (!ret || !ao) return NULL;
RBinInfo *ret;
if (!ao) return NULL;
ret = R_NEW0 (RBinInfo);
if (!ret) return NULL;
//art_header_load (&art, arch->buf);

View File

@ -784,8 +784,12 @@ void build_command_field(ELeafType lt, char **command_field) {
///////////////////////////////////////////////////////////////////////////////
void build_name_field(char *name, char **name_field) {
*name_field = (char *) malloc(strlen(name) + 1);
strcpy(*name_field, name);
if (!name) {
*name_field = NULL;
} else {
*name_field = (char *) malloc(strlen(name) + 1);
strcpy(*name_field, name);
}
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -209,7 +209,6 @@ R_API void r_cons_canvas_write(RConsCanvas *c, const char *s) {
piece_len = get_piece (s_part, &ch);
if (piece_len == 0 && ch == '\0' && s_part == s) break;
slen = 0;
p = prefixline (c, &left);
slen = R_MIN (left, piece_len);
attr_len = slen <= 0 && s_part != s ? 1 : slen;

View File

@ -863,7 +863,6 @@ R_API const char *r_line_readline_cb(RLineReadCallback cb, void *user) {
#endif
if (I.echo)
r_cons_clear_line (0);
columns = r_cons_get_size (NULL)-2;
if (columns<1)
columns = 40;
#if __WINDOWS__ && !__CYGWIN__

View File

@ -465,8 +465,6 @@ static RList * r_core_asm_back_disassemble_all(RCore *core, ut64 addr, ut64 len,
return hits;
}
current_buf_pos = len - 1;
do {
if (r_cons_singleton ()->breaked) break;
// reset assembler

View File

@ -177,14 +177,16 @@ rep:
break;
case '+':
case ' ': {
char *s = strchr (str, ' '), *s2 = NULL, *eq = strchr (str, '=');
char* eq = strchr (str, '=');
char* s = strchr (str, ' ');
char* s2 = NULL;
ut32 bsze = 1; //core->blocksize;
if (eq) {
// TODO: add support for '=' char in flag comments
*eq = 0;
off = r_num_math (core->num, eq+1);
}
s = strchr (str, ' ');
if (s) {
*s = '\0';
s2 = strchr (s+1, ' ');

View File

@ -369,12 +369,11 @@ static int cmd_meta_comment(RCore *core, const char *input) {
// Comment at
if (p) {
if (input[2]=='+') {
char *text = p;
char *comment = r_meta_get_string (
core->anal, R_META_TYPE_COMMENT,
addr);
if (comment) {
text = malloc (strlen (comment) + strlen (p)+2);
char* text = malloc (strlen (comment) + strlen (p)+2);
strcpy (text, comment);
strcat (text, "\n");
strcat (text, p);

View File

@ -3056,8 +3056,8 @@ static int cmd_print(void *data, const char *input) {
int oldva = core->io->va;
int do_zoom = 1;
from = 0;
core->io->va = 0;
from = 0;
to = r_io_size (core->io);
from = r_config_get_i (core->config, "zoom.from");
to = r_config_get_i (core->config, "zoom.to");

View File

@ -120,21 +120,20 @@ static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) {
}
} else {
mal->size = r_num_math (NULL, pathname+9);
mal->offset = 0;
if (((int)(mal->size))>0) {
mal->buf = malloc (mal->size+1);
memset (mal->buf, '\0', mal->size);
} else {
if (((int)mal->size) <= 0) {
free (mal);
eprintf ("Cannot allocate (%s) 0 bytes\n", pathname+9);
return NULL;
}
mal->offset = 0;
mal->buf = malloc (mal->size+1);
}
if (mal->buf != NULL) {
memset (mal->buf, '\0', mal->size);
RETURN_IO_DESC_NEW (&r_io_plugin_malloc,
mal->fd, pathname, rw, mode,mal);
}
eprintf ("Cannot allocate (%s) %d bytes\n", pathname+9,
mal->size);
eprintf ("Cannot allocate (%s) %d bytes\n", pathname+9, mal->size);
free (mal);
}
return NULL;

View File

@ -160,8 +160,10 @@ static RIODesc *rap__open(struct r_io_t *io, const char *pathname, int rw, int m
rior = R_NEW (RIORap);
rior->listener = R_TRUE;
rior->client = rior->fd = r_socket_new (is_ssl);
if (rior->fd == NULL)
if (rior->fd == NULL) {
free (rior);
return NULL;
}
if (is_ssl) {
if (file && *file) {
if (!r_socket_listen (rior->fd, port, file)) {