Skip to content

Commit

Permalink
Refix for #2889 - that was nasty
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Jul 8, 2015
1 parent 7a937e4 commit a870a9f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
9 changes: 6 additions & 3 deletions libr/core/core.c
Expand Up @@ -146,9 +146,12 @@ static ut64 num_callback(RNum *userptr, const char *str, int *ok) {
char *o = strdup (str+1);
if (o) {
q = r_num_calc_index (core->num, NULL);
r_str_replace_char (o, ']', 0);
n = r_num_math (core->num, o);
r_num_calc_index (core->num, q);
if (q) {
if (r_str_replace_char (o, ']', 0)>0) {
n = r_num_math (core->num, o);
r_num_calc_index (core->num, q);
}
}
free (o);
}
}
Expand Down
8 changes: 1 addition & 7 deletions libr/util/calc.c
Expand Up @@ -145,18 +145,12 @@ static void cin_putback (RNum *num, RNumCalc *nc, char c) {
}

R_API const char *r_num_calc_index (RNum *num, const char *p) {
if (num == NULL)
return NULL;
if (!num) return NULL;
if (p) {
num->nc.calc_buf = p;
num->nc.calc_len = strlen (p);
num->nc.calc_i = 0;
} else {
num->nc.calc_buf = NULL;
num->nc.calc_len = 0;
num->nc.calc_i = 0;
}
//if (num->nc.calc_i>num->nc.calc_len) return NULL;
return num->nc.calc_buf + num->nc.calc_i;
}

Expand Down
5 changes: 3 additions & 2 deletions libr/util/num.c
Expand Up @@ -119,8 +119,9 @@ R_API ut64 r_num_get(RNum *num, const char *str) {
if (ok) return ret;
}

if (str[0]=='\'' && str[2]=='\'')
return (ut64)str[1];
if (str[0] && str[1] && str[2])
if (str[0]=='\'' && str[2]=='\'')
return (ut64)str[1];

len = strlen (str);
if (len>3 && str[4] == ':') {
Expand Down

0 comments on commit a870a9f

Please sign in to comment.