Skip to content

Commit 201231a

Browse files
committedMay 8, 2014
Fix remaining segfault in RCons.canvas, still trashy output
1 parent 7fa79a3 commit 201231a

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed
 

‎Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ MAKE_JOBS?=1
2323

2424
all: plugins.cfg
2525
${MAKE} -C libr/util
26-
${MAKE} -j$(MAKE_JOBS) -C shlr
27-
${MAKE} -j$(MAKE_JOBS) -C libr
28-
${MAKE} -j$(MAKE_JOBS) -C binr
26+
${MAKE} -C shlr
27+
${MAKE} -C libr
28+
${MAKE} -C binr
2929

3030
plugins.cfg:
3131
@if [ ! -e config-user.mk ]; then echo ; \

‎libr/cons/canvas.c

+14-5
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,20 @@ R_API void r_cons_canvas_line (RConsCanvas *c, int x, int y, int x2, int y2, int
233233
memset (row+1, '-', w-2);
234234
row[w-1] = '\'';
235235
row[w] = 0;
236-
onscreen = G (x2,y+hl+1);
236+
onscreen = G (x2+w,y+hl+1);
237+
i = G (x2, y+hl+1);
238+
if (!onscreen)
239+
onscreen = i;
237240
} else {
238241
row[0] = '`';
239242
if (w>1)
240243
memset (row+1, '-', w-1);
241244
row[w] = '.';
242245
row[w+1] = 0;
243-
onscreen = G (x,y+1+hl);
246+
onscreen = G (x+w,y+1+hl);
247+
i = G (x,y+1+hl);
248+
if (!onscreen)
249+
onscreen = i;
244250
}
245251
if (onscreen)
246252
W (row);
@@ -279,20 +285,23 @@ R_API void r_cons_canvas_line (RConsCanvas *c, int x, int y, int x2, int y2, int
279285
W (row);
280286

281287
w = rl2;
288+
free (row);
289+
row = malloc (rl2+1);
282290
if (x>x2) {
283291
row[0] = '`';
284292
memset (row+1, '-', w-2);
285293
row[w-1] = '\'';
286294
row[w] = 0;
287-
G (x2+rl, y+1);
295+
onscreen = G (x2+rl, y+1);
288296
} else {
289297
row[0] = '.';
290298
memset (row+1, '-', w-2);
291299
row[w-1] = '.';
292300
row[w] = 0;
293-
G (x+rl, y2-1);
301+
onscreen = G (x+rl, y2-1);
294302
}
295-
W (row);
303+
if (onscreen)
304+
W (row);
296305
free (row);
297306
}
298307
}

‎libr/core/graph.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ static int Node_find(const Node* nodes, ut64 addr) {
106106
return -1;
107107
}
108108

109-
110109
static void Layout_depth2(Node *nodes, Edge *edges, int nth, int depth) {
111110
int j, f;
112111
if (!nodes || !nodes[nth].text)
@@ -189,7 +188,6 @@ R_API int r_core_visual_graph(RCore *core, RAnalFunction *_fcn) {
189188
can = r_cons_canvas_new (w-1, h-1);
190189

191190
nodes = malloc (sizeof(Node)*(r_list_length (fcn->bbs)+1));
192-
edges = NULL;
193191
i = 0;
194192
r_list_foreach (fcn->bbs, iter, bb) {
195193
nodes[i].text = r_core_cmd_strf (core,
@@ -206,17 +204,18 @@ R_API int r_core_visual_graph(RCore *core, RAnalFunction *_fcn) {
206204
n_nodes = i;
207205

208206
i = 0;
207+
edges = NULL;
209208
n_edges = 0;
210209
r_list_foreach (fcn->bbs, iter, bb) {
211210
// add edge from bb->addr to bb->jump / bb->fail
212211
if (bb->jump != UT64_MAX) {
213-
edges = realloc(edges, sizeof (Edge)*(i+1));
212+
edges = realloc (edges, sizeof (Edge)*(i+2));
214213
edges[i].nth = 0;
215214
edges[i].from = Node_find (nodes, bb->addr);
216215
edges[i].to = Node_find (nodes, bb->jump);
217216
i++;
218217
if (bb->fail != UT64_MAX) {
219-
edges = realloc(edges, sizeof (Edge)*(i+1));
218+
edges = realloc (edges, sizeof (Edge)*(i+2));
220219
edges[i].nth = 1;
221220
edges[i].from = Node_find (nodes, bb->addr);
222221
edges[i].to = Node_find (nodes, bb->fail);
@@ -296,6 +295,10 @@ prevnode = curnode;
296295
case 's': can->sy += 1; break;
297296
case 'a': can->sx -= 1; break;
298297
case 'd': can->sx += 1; break;
298+
case 'W': can->sy -= 5; break;
299+
case 'S': can->sy += 5; break;
300+
case 'A': can->sx -= 5; break;
301+
case 'D': can->sx += 5; break;
299302
break;
300303
case 'u':
301304
curnode = prevnode;

‎libr/stripsyms.sh

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/sh
22

3+
# skip this thing. it slow downs the build too much
4+
exit 0
5+
36
[ -n "${NOSTRIP}" ] && exit 0
47

58
[ -z "$2" ] && exit 0

0 commit comments

Comments
 (0)
Please sign in to comment.