Skip to content

Commit

Permalink
Fix some infers
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarofe authored and radare committed Jun 28, 2015
1 parent ccef928 commit daf8e5b
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 10 deletions.
4 changes: 3 additions & 1 deletion libr/bin/dwarf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1327,8 +1327,9 @@ R_API int r_bin_dwarf_parse_info_raw(Sdb *s, RBinDwarfDebugAbbrev *da,
RBinDwarfDebugInfo *inf = NULL, di;
inf = &di;

r_bin_dwarf_init_debug_info (inf);
if (!da || !s || !obuf) return R_FALSE;

r_bin_dwarf_init_debug_info (inf);
while (buf < buf_end) {
if (inf->length >= inf->capacity)
break;
Expand Down Expand Up @@ -1499,6 +1500,7 @@ R_API int r_bin_dwarf_parse_info(RBinDwarfDebugAbbrev *da, RBin *a, int mode) {

static RBinDwarfRow *r_bin_dwarf_row_new (ut64 addr, const char *file, int line, int col) {
RBinDwarfRow *row = R_NEW0 (RBinDwarfRow);
if (!row) return NULL;
row->file = strdup (file);
row->address = addr;
row->line = line;
Expand Down
5 changes: 3 additions & 2 deletions libr/bin/mangling/cxx/cp-demangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -2019,10 +2019,10 @@ cplus_demangle_type (struct d_info *di)

pret = d_cv_qualifiers (di, &ret, 0);
if (pret == NULL)
return NULL;
return NULL;
*pret = cplus_demangle_type (di);
if (! *pret || ! d_add_substitution (di, ret))
return NULL;
return NULL;
return ret;
}

Expand All @@ -2036,6 +2036,7 @@ cplus_demangle_type (struct d_info *di)
case 'v': case 'w': case 'x': case 'y': case 'z':
ret = d_make_builtin_type (di,
&cplus_demangle_builtin_types[peek - 'a']);
if (!ret) return NULL;
di->expansion += ret->u.s_builtin.type->len;
can_subst = 0;
d_advance (di, 1);
Expand Down
1 change: 1 addition & 0 deletions libr/bin/mangling/microsoft_demangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ int get_namespace_and_name( char *buf, STypeCodeStr *type_code_str,

#define SET_OPERATOR_CODE(str) { \
str_info = (SStrInfo *) malloc(sizeof(SStrInfo)); \
if (!str_info) break; \
str_info->len = strlen(str); \
str_info->str_ptr = str; \
r_list_append(names_l, str_info); \
Expand Down
2 changes: 2 additions & 0 deletions libr/bin/pdb/pdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,14 @@ static int pdb_read_root(R_PDB *pdb) {
// look default
case ePDB_STREAM_PDB:
pdb_info_stream = R_NEW0 (SPDBInfoStream);
if (!pdb_info_stream) return 0;
pdb_info_stream->free_ = free_info_stream;
parse_pdb_info_stream(pdb_info_stream, &stream_file);
r_list_append(pList, pdb_info_stream);
break;
case ePDB_STREAM_TPI:
tpi_stream = R_NEW0 (STpiStream);
if (!tpi_stream) return 0;
init_tpi_stream(tpi_stream);
if (!parse_tpi_stream(tpi_stream, &stream_file)) {
free (tpi_stream);
Expand Down
2 changes: 2 additions & 0 deletions libr/bin/pdb/pdb_downloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ static int download(struct SPDBDownloader *pd) {
// dbg_file len is > 0
archive_name_len = strlen (opt->dbg_file);
archive_name = malloc (archive_name_len+1);
if (!archive_name) return 0;
memcpy (archive_name, opt->dbg_file, archive_name_len+1);

archive_name[archive_name_len-1] = '_';
Expand Down Expand Up @@ -95,6 +96,7 @@ static int download(struct SPDBDownloader *pd) {

void init_pdb_downloader(SPDBDownloaderOpt *opt, SPDBDownloader *pd) {
pd->opt = R_NEW0 (SPDBDownloaderOpt);
if (!pd->opt) return;
pd->opt->dbg_file = strdup(opt->dbg_file);
pd->opt->guid = strdup(opt->guid);
pd->opt->symbol_server = strdup(opt->symbol_server);
Expand Down
12 changes: 11 additions & 1 deletion libr/bp/traptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,23 @@ R_API int r_bp_traptrace_add(RBreakpoint *bp, ut64 from, ut64 to) {
r_bp_get_bytes (bp, trap, len, bp->endian, 0);

trace = R_NEW (RBreakpointTrace);
if (!trace) {
free (buf);
free (trap);
return R_FALSE;
}
trace->addr = from;
trace->addr_end = to;
trace->bits = bits;
trace->traps = trap;
trace->buffer = buf;
trace->length = len;
r_list_append (bp->traces, trace);
if (!r_list_append (bp->traces, trace)){
free (buf);
free (trap);
free (trace);
return R_FALSE;
}
// read a memory, overwrite it as breakpointing area
// everytime it is hitted, instruction is restored
return R_TRUE;
Expand Down
11 changes: 8 additions & 3 deletions libr/cons/hud.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ R_API char *r_cons_hud_file(const char *f) {

R_API char *r_cons_hud_string(const char *s) {
int i;
char *os, *ret, *o = strdup (s);
char *os, *track, *ret, *o = strdup (s);
RList *fl = r_list_new ();
if (!fl) {
free (o);
Expand All @@ -39,8 +39,13 @@ R_API char *r_cons_hud_string(const char *s) {
for (os=o, i=0; o[i]; i++) {
if (o[i]=='\n') {
o[i] = 0;
if (*os && *os != '#')
r_list_append (fl, strdup (os));
if (*os && *os != '#'){
track = strdup (os);
if (!r_list_append (fl, track)){
free (track);
break;
}
}
os = o + i + 1;
}
}
Expand Down
5 changes: 4 additions & 1 deletion libr/core/asm.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,10 @@ static void add_hit_to_hits(RList* hits, ut64 addr, int len, ut8 is_valid) {
hit->len = len;
hit->valid = is_valid;
hit->code = NULL;
r_list_append (hits, hit);
if (!r_list_append (hits, hit)){
free (hit);
IFDBG eprintf ("hit couldn't be added to the list in %s at %d\n", __FILE__, __LINE__);
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion libr/core/cmd_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ R_API int r_cmd_add_long(RCmd *cmd, const char *lcmd, const char *scmd, const ch
strncpy (item->cmd_short, scmd, sizeof (item->cmd_short)-1);
item->cmd_len = strlen (lcmd);
strncpy (item->desc, desc, sizeof (item->desc)-1);
r_list_append (cmd->lcmds, item);
if (!r_list_append (cmd->lcmds, item)){
free (item);
return R_FALSE;
}
return R_TRUE;
}

Expand Down
6 changes: 5 additions & 1 deletion libr/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,8 @@ R_API int r_core_serve(RCore *core, RIODesc *file) {
return -1;
if (c == NULL) {
eprintf ("rap: cannot accept\n");
r_socket_close (c);
/*r_socket_close (c);*/
r_socket_free (c);
return -1;
}
eprintf ("rap: client connected\n");
Expand All @@ -1220,6 +1221,8 @@ R_API int r_core_serve(RCore *core, RIODesc *file) {
eprintf ("rap: connection closed\n");
if (r_config_get_i (core->config, "rap.loop")) {
eprintf ("rap: waiting for new connection\n");
/*r_socket_close (c);*/
r_socket_free (c);
goto reaccept;
}
return -1;
Expand Down Expand Up @@ -1255,6 +1258,7 @@ R_API int r_core_serve(RCore *core, RIODesc *file) {
} else {
pipefd = -1;
eprintf ("Cannot open file (%s)\n", ptr);
r_socket_close (c);
return -1; //XXX: Close conection and goto accept
}
}
Expand Down

0 comments on commit daf8e5b

Please sign in to comment.