mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-13 10:24:45 +00:00
Fix last coverity issues (#16114)
This commit is contained in:
parent
d573241c47
commit
b82b24c135
@ -2519,10 +2519,9 @@ static int bin_map_sections_to_segments (RBin *bin, int mode) {
|
||||
r_list_append (list, section);
|
||||
}
|
||||
|
||||
char *tmp2 = NULL;
|
||||
r_list_foreach (segments, iter, segment) {
|
||||
RInterval segment_itv = (RInterval){segment->vaddr, segment->size};
|
||||
tmp2 = r_str_new ("");
|
||||
char *tmp2 = r_str_new ("");
|
||||
r_list_foreach (sections, iter2, section) {
|
||||
RInterval section_itv = (RInterval){section->vaddr, section->size};
|
||||
if (r_itv_begin (section_itv) >= r_itv_begin (segment_itv) && r_itv_end (section_itv) <= r_itv_end (segment_itv) && section->name[0]) {
|
||||
@ -2532,17 +2531,25 @@ static int bin_map_sections_to_segments (RBin *bin, int mode) {
|
||||
r_table_add_row (table, segment->name, tmp2, 0);
|
||||
/*output to json*/
|
||||
json_output = r_str_appendf (json_output, "\"%s\": \"%s\",", segment->name, tmp2);
|
||||
free (tmp2);
|
||||
}
|
||||
// remove last ,
|
||||
json_output [strlen (json_output) - 1] = 0;
|
||||
json_output = r_str_newf ("[{%s}]", json_output);
|
||||
char *jo = r_str_newf ("[{%s}]", json_output);
|
||||
free (json_output);
|
||||
json_output = jo;
|
||||
|
||||
if (IS_MODE_JSON (mode)){
|
||||
r_cons_printf ("%s", json_output);
|
||||
} else if (IS_MODE_NORMAL (mode)){
|
||||
r_cons_printf ("Section to Segment mapping:\n");
|
||||
r_cons_printf ("%s\n", r_table_tostring (table));
|
||||
char *s = r_table_tostring (table);
|
||||
r_cons_printf ("%s\n", s);
|
||||
free (s);
|
||||
}
|
||||
free (json_output);
|
||||
r_list_free (segments);
|
||||
r_table_free (table);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2534,13 +2534,8 @@ static int r_core_cmd_subst(RCore *core, char *cmd) {
|
||||
if (core->max_cmd_depth - core->cons->context->cmd_depth == 1) {
|
||||
core->prompt_offset = core->offset;
|
||||
}
|
||||
#if 0
|
||||
r_str_trim (icmd);
|
||||
cmd = icmd;
|
||||
#else
|
||||
cmd = (char *)r_str_trim_head_ro (icmd);
|
||||
r_str_trim_tail (cmd);
|
||||
#endif
|
||||
// lines starting with # are ignored (never reach cmd_hash()), except #! and #?
|
||||
if (!*cmd) {
|
||||
if (core->cmdrepeat > 0) {
|
||||
|
@ -2072,9 +2072,9 @@ R_API void r_core_debug_rr(RCore *core, RReg *reg, int mode) {
|
||||
}
|
||||
|
||||
char *namestr = r_str_newf ("%s%s%s", color, r->name, colorend);
|
||||
char *valuestr = r_str_newf ("%s%X%s", color, value, colorend);
|
||||
char *valuestr = r_str_newf ("%s%"PFMT64x"%s", color, value, colorend);
|
||||
|
||||
char *rrstr = "";
|
||||
char *rrstr = strdup ("");
|
||||
char *refs = r_core_anal_hasrefs (core, value, true);
|
||||
if (refs) {
|
||||
rrstr = refs;
|
||||
@ -2086,11 +2086,9 @@ R_API void r_core_debug_rr(RCore *core, RReg *reg, int mode) {
|
||||
free (rrstr);
|
||||
}
|
||||
|
||||
if (mode == 'j') {
|
||||
r_cons_print (r_table_tojson (t));
|
||||
} else {
|
||||
r_cons_print (r_table_tostring (t));
|
||||
}
|
||||
char *s = (mode == 'j')? r_table_tojson(t): r_table_tostring(t);
|
||||
r_cons_print (s);
|
||||
free (s);
|
||||
r_table_free (t);
|
||||
|
||||
if (use_colors) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user