From 8ed95246d72691a0e8de799ff71ed409d5ea8f36 Mon Sep 17 00:00:00 2001 From: pancake Date: Fri, 9 Sep 2016 14:02:28 +0200 Subject: [PATCH] Fix esil expression for x86 --- libr/anal/p/anal_x86_cs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libr/anal/p/anal_x86_cs.c b/libr/anal/p/anal_x86_cs.c index 8fa2dbfb78..308fa243e4 100644 --- a/libr/anal/p/anal_x86_cs.c +++ b/libr/anal/p/anal_x86_cs.c @@ -169,18 +169,21 @@ static char *getarg(struct Getarg* gop, int n, int set, char *setop) { strncpy (buf, buf_, sizeof (buf)); } else { // Remove the trailing ',' from esil statement. - if (strlen(buf)) buf[strlen(buf) - 1] = '\0'; + if (*buf) { + buf[strlen (buf) - 1] = 0; + } } // set = 2 is reserved for lea, where the operand is a memory address, // but the corresponding memory is not loaded. if (set == 1) { snprintf (buf_, sizeof (buf), "%s,%s=[%d]", buf, setarg, op.size==10?8:op.size); + strncpy (buf, buf_, sizeof (buf)); } else if (set == 0) { snprintf (buf_, sizeof (buf), "%s,[%d]", buf, op.size==10? 8: op.size); + strncpy (buf, buf_, sizeof (buf)); } - strncpy (buf, buf_, sizeof (buf)); buf[sizeof (buf) - 1] = 0; } return strdup (buf);