fix if-statement depth for esil expressions

This commit is contained in:
condret 2018-09-13 23:47:44 +00:00
parent 07e1359daf
commit 748785852d
2 changed files with 14 additions and 6 deletions

View File

@ -1021,13 +1021,17 @@ static int esil_ifset(RAnalEsil *esil) {
static int esil_if(RAnalEsil *esil) {
ut64 num = 0LL;
if (esil->skip) {
esil->skip++;
return true;
}
char *src = r_anal_esil_pop (esil);
if (src) {
// TODO: check return value
(void)r_anal_esil_get_parm (esil, src, &num);
// condition not matching, skipping until }
if (!num) {
esil->skip = true;
esil->skip++;
}
free (src);
return true;
@ -2814,13 +2818,17 @@ static int runword(RAnalEsil *esil, const char *word) {
//eprintf ("WORD (%d) (%s)\n", esil->skip, word);
if (!strcmp (word, "}{")) {
esil->skip = esil->skip? 0: 1;
if (esil->skip == 1) {
esil->skip = 0;
}
return 1;
} else if (!strcmp (word, "}")) {
esil->skip = 0;
if (esil->skip) {
esil->skip--;
}
return 1;
}
if (esil->skip) {
if (esil->skip && strcmp(word, "?{")) {
return 1;
}

View File

@ -1087,7 +1087,7 @@ typedef struct r_anal_esil_t {
ut64 addrmask;
int stacksize;
int stackptr;
int skip;
ut32 skip;
int nowrite;
int iotrap;
int exectrap;
@ -1127,7 +1127,7 @@ typedef struct r_anal_esil_t {
char *mdev_range; // string containing the r_str_range to match for read/write accesses
bool (*cmd)(ESIL *esil, const char *name, ut64 a0, ut64 a1);
void *user;
int stack_fd;
int stack_fd; // ahem, let's not do this
RList *sessions; // <RAnalEsilSession*>
} RAnalEsil;