Skip to content

Instantly share code, notes, and snippets.

@crowell
Created January 19, 2016 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crowell/6cae90fdeb3810d3f695 to your computer and use it in GitHub Desktop.
Save crowell/6cae90fdeb3810d3f695 to your computer and use it in GitHub Desktop.
diff --git a/libr/anal/esil.c b/libr/anal/esil.c
index 7b5cf2d..0ff8a72 100644
--- a/libr/anal/esil.c
+++ b/libr/anal/esil.c
@@ -1988,14 +1988,16 @@ static int esil_dup(RAnalEsil *esil) {
}
static int esil_swap (RAnalEsil *esil) {
- char *tmp;
+ char *tmp1;
+ char *tmp2;
if (!esil || !esil->stack || esil->stackptr < 2)
return false;
- if (!esil->stack[esil->stackptr] || !esil->stack[esil->stackptr-1])
+ if (!esil->stack[esil->stackptr-1] || !esil->stack[esil->stackptr-2])
return false;
- tmp = esil->stack[esil->stackptr];
- esil->stack[esil->stackptr] = esil->stack[esil->stackptr-1];
- esil->stack[esil->stackptr-1] = tmp;
+ tmp1 = r_anal_esil_pop (esil);
+ tmp2 = r_anal_esil_pop (esil);
+ r_anal_esil_push (esil, tmp1);
+ r_anal_esil_push (esil, tmp2);
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment