Fix two null deref in RConsCanvas and another left border glitch
This commit is contained in:
parent
c042bcd789
commit
377ec87272
2 changed files with 13 additions and 5 deletions
|
|
@ -75,7 +75,9 @@ static char *getptr(RConsCanvas *c, int *left) {
|
|||
#endif
|
||||
|
||||
static char *getrow (char *p, char **n) {
|
||||
char *q = strchr (p, '\n');
|
||||
char *q;
|
||||
if (!p) return NULL;
|
||||
q = strchr (p, '\n');
|
||||
if (n) *n = NULL;
|
||||
if (q) {
|
||||
*q = 0;
|
||||
|
|
@ -108,6 +110,8 @@ R_API void r_cons_canvas_write(RConsCanvas *c, const char *_s) {
|
|||
str = s = strdup (_s);
|
||||
for (i=0; ; i++) {
|
||||
line = getrow (s, &n);
|
||||
if (!line)
|
||||
break;
|
||||
p = prefixline (c, &left);
|
||||
slen = R_MIN (left-1, strlen (line));
|
||||
if (slen<1) {
|
||||
|
|
@ -126,7 +130,9 @@ R_API void r_cons_canvas_write(RConsCanvas *c, const char *_s) {
|
|||
// continue;
|
||||
//}
|
||||
int delta = 0;
|
||||
if (!G (c->x-c->sx-slen, c->y-c->sy))
|
||||
int x = c->x - c->sx -slen;
|
||||
if (x<0) x=0;
|
||||
if (!G (x, c->y-c->sy))
|
||||
continue;
|
||||
memcpy (p, line+delta, slen-delta);
|
||||
if (!n) break;
|
||||
|
|
|
|||
|
|
@ -97,6 +97,8 @@ static void Node_print(RConsCanvas *can, Node *n, int cur) {
|
|||
if (x<-2) {
|
||||
delta_x = -x-2;
|
||||
}
|
||||
if (x+n->w<-2)
|
||||
return;
|
||||
if (y<-1) {
|
||||
delta_y = -y-2;
|
||||
}
|
||||
|
|
@ -110,13 +112,13 @@ static void Node_print(RConsCanvas *can, Node *n, int cur) {
|
|||
" 0x%08"PFMT64x" ", n->addr);
|
||||
}
|
||||
if (G (n->x+1, n->y+1))
|
||||
W (title);
|
||||
G (n->x+2, n->y+2);
|
||||
W (title); // delta_x
|
||||
G (n->x+2+delta_x, n->y+2);
|
||||
//if (
|
||||
// TODO: temporary crop depending on out of screen offsets
|
||||
{
|
||||
char *text = r_str_crop (n->text,
|
||||
delta_x, delta_y, 9999, 9999);
|
||||
delta_x, delta_y, n->w, n->h);
|
||||
if (text) {
|
||||
W (text);
|
||||
free (text);
|
||||
|
|
|
|||
Loading…
Reference in a new issue