Skip to content

Commit 96343ee

Browse files
committed
asdf
1 parent 73066c1 commit 96343ee

File tree

1 file changed

+42
-35
lines changed

1 file changed

+42
-35
lines changed

libr/esil/esil_ops.c

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,16 +1723,17 @@ static bool esil_mem_addeq_n(REsil *esil, int bits) {
17231723
bool ret = false;
17241724
ut64 s, d;
17251725
const char *dst = r_esil_pop (esil);
1726+
char dst_buf[R_ESIL_TOKEN_SIZE];
17261727
const char *src0 = r_esil_pop (esil);
1727-
const char *src1 = NULL;
1728-
if (src0 && r_esil_get_parm (esil, src0, &s)) {
1729-
r_esil_push (esil, dst);
1728+
if (dst && src0 && r_esil_get_parm (esil, src0, &s)) {
1729+
r_str_ncpy (dst_buf, dst, sizeof (dst_buf));
1730+
r_esil_push (esil, dst_buf);
17301731
ret = !!esil_peek_n (esil, bits);
1731-
src1 = r_esil_pop (esil);
1732+
const char *src1 = r_esil_pop (esil);
17321733
if (src1 && r_esil_get_parm (esil, src1, &d)) {
17331734
d += s;
17341735
r_esil_pushnum (esil, d);
1735-
r_esil_push (esil, dst);
1736+
r_esil_push (esil, dst_buf);
17361737
ret &= (!!esil_poke_n (esil, bits));
17371738
} else {
17381739
ret = false;
@@ -1763,16 +1764,17 @@ static bool esil_mem_subeq_n(REsil *esil, int bits) {
17631764
bool ret = false;
17641765
ut64 s, d;
17651766
const char *dst = r_esil_pop (esil);
1767+
char dst_buf[R_ESIL_TOKEN_SIZE];
17661768
const char *src0 = r_esil_pop (esil);
1767-
const char *src1 = NULL;
1768-
if (src0 && r_esil_get_parm (esil, src0, &s)) {
1769-
r_esil_push (esil, dst);
1769+
if (dst && src0 && r_esil_get_parm (esil, src0, &s)) {
1770+
r_str_ncpy (dst_buf, dst, sizeof (dst_buf));
1771+
r_esil_push (esil, dst_buf);
17701772
ret = !!esil_peek_n (esil, bits);
1771-
src1 = r_esil_pop (esil);
1773+
const char *src1 = r_esil_pop (esil);
17721774
if (src1 && r_esil_get_parm (esil, src1, &d)) {
17731775
d -= s;
17741776
r_esil_pushnum (esil, d);
1775-
r_esil_push (esil, dst);
1777+
r_esil_push (esil, dst_buf);
17761778
ret &= !!esil_poke_n (esil, bits);
17771779
} else {
17781780
ret = false;
@@ -1803,22 +1805,23 @@ static bool esil_mem_modeq_n(REsil *esil, int bits) {
18031805
bool ret = false;
18041806
ut64 s, d;
18051807
const char *dst = r_esil_pop (esil);
1808+
char dst_buf[R_ESIL_TOKEN_SIZE];
18061809
const char *src0 = r_esil_pop (esil);
1807-
const char *src1 = NULL;
1808-
if (src0 && r_esil_get_parm (esil, src0, &s)) {
1810+
if (dst && src0 && r_esil_get_parm (esil, src0, &s)) {
1811+
r_str_ncpy (dst_buf, dst, sizeof (dst_buf));
18091812
if (s == 0) {
18101813
R_LOG_DEBUG ("esil_mem_modeq4: Division by zero!");
18111814
esil->trap = R_ANAL_TRAP_DIVBYZERO;
18121815
esil->trap_code = 0;
18131816
} else {
1814-
r_esil_push (esil, dst);
1817+
r_esil_push (esil, dst_buf);
18151818
ret = !!esil_peek_n (esil, bits);
1816-
src1 = r_esil_pop (esil);
1819+
const char *src1 = r_esil_pop (esil);
18171820
if (src1 && r_esil_get_parm (esil, src1, &d) && s >= 1) {
18181821
r_esil_pushnum (esil, d % s);
18191822
d = d % s;
18201823
r_esil_pushnum (esil, d);
1821-
r_esil_push (esil, dst);
1824+
r_esil_push (esil, dst_buf);
18221825
ret &= (!!esil_poke_n (esil, bits));
18231826
} else {
18241827
ret = false;
@@ -1850,21 +1853,22 @@ static bool esil_mem_diveq_n(REsil *esil, int bits) {
18501853
bool ret = false;
18511854
ut64 s, d;
18521855
const char *dst = r_esil_pop (esil);
1856+
char dst_buf[R_ESIL_TOKEN_SIZE];
18531857
const char *src0 = r_esil_pop (esil);
1854-
const char *src1 = NULL;
1855-
if (src0 && r_esil_get_parm (esil, src0, &s)) {
1858+
if (dst && src0 && r_esil_get_parm (esil, src0, &s)) {
1859+
r_str_ncpy (dst_buf, dst, sizeof (dst_buf));
18561860
if (s == 0) {
18571861
R_LOG_DEBUG ("esil_mem_diveq8: Division by zero!");
18581862
esil->trap = R_ANAL_TRAP_DIVBYZERO;
18591863
esil->trap_code = 0;
18601864
} else {
1861-
r_esil_push (esil, dst);
1865+
r_esil_push (esil, dst_buf);
18621866
ret = !!esil_peek_n (esil, bits);
1863-
src1 = r_esil_pop (esil);
1867+
const char *src1 = r_esil_pop (esil);
18641868
if (src1 && r_esil_get_parm (esil, src1, &d)) {
18651869
d = d / s;
18661870
r_esil_pushnum (esil, d);
1867-
r_esil_push (esil, dst);
1871+
r_esil_push (esil, dst_buf);
18681872
ret &= (!!esil_poke_n (esil, bits));
18691873
} else {
18701874
ret = false;
@@ -1896,16 +1900,17 @@ static bool esil_mem_muleq_n(REsil *esil, int bits, ut64 bitmask) {
18961900
bool ret = false;
18971901
ut64 s, d;
18981902
const char *dst = r_esil_pop (esil);
1903+
char dst_buf[R_ESIL_TOKEN_SIZE];
18991904
const char *src0 = r_esil_pop (esil);
1900-
const char *src1 = NULL;
1901-
if (src0 && r_esil_get_parm (esil, src0, &s)) {
1902-
r_esil_push (esil, dst);
1905+
if (dst && src0 && r_esil_get_parm (esil, src0, &s)) {
1906+
r_str_ncpy (dst_buf, dst, sizeof (dst_buf));
1907+
r_esil_push (esil, dst_buf);
19031908
ret = !!esil_peek_n (esil, bits);
1904-
src1 = r_esil_pop (esil);
1909+
const char *src1 = r_esil_pop (esil);
19051910
if (src1 && r_esil_get_parm (esil, src1, &d)) {
19061911
d *= s;
19071912
r_esil_pushnum (esil, d);
1908-
r_esil_push (esil, dst);
1913+
r_esil_push (esil, dst_buf);
19091914
ret &= (!!esil_poke_n (esil, bits));
19101915
} else {
19111916
ret = false;
@@ -2019,23 +2024,24 @@ static bool esil_mem_lsleq_n(REsil *esil, int bits) {
20192024
bool ret = false;
20202025
ut64 s, d;
20212026
const char *dst = r_esil_pop (esil);
2027+
char dst_buf[R_ESIL_TOKEN_SIZE];
20222028
const char *src0 = r_esil_pop (esil);
2023-
const char *src1 = NULL;
2024-
if (src0 && r_esil_get_parm (esil, src0, &s)) {
2029+
if (dst && src0 && r_esil_get_parm (esil, src0, &s)) {
2030+
r_str_ncpy (dst_buf, dst, sizeof (dst_buf));
20252031
if (s > sizeof (ut64) * 8) {
20262032
R_LOG_DEBUG ("esil_mem_lsleq_n: shift is too big");
20272033
} else {
2028-
r_esil_push (esil, dst);
2034+
r_esil_push (esil, dst_buf);
20292035
ret = !!esil_peek_n (esil, bits);
2030-
src1 = r_esil_pop (esil);
2036+
const char *src1 = r_esil_pop (esil);
20312037
if (src1 && r_esil_get_parm (esil, src1, &d)) {
20322038
if (s > 63) {
20332039
d = 0;
20342040
} else {
20352041
d <<= s;
20362042
}
20372043
r_esil_pushnum (esil, d);
2038-
r_esil_push (esil, dst);
2044+
r_esil_push (esil, dst_buf);
20392045
ret &= (!!esil_poke_n (esil, bits));
20402046
} else {
20412047
ret = false;
@@ -2067,16 +2073,17 @@ static bool esil_mem_lsreq_n(REsil *esil, int bits) {
20672073
bool ret = false;
20682074
ut64 s, d;
20692075
const char *dst = r_esil_pop (esil);
2076+
char dst_buf[R_ESIL_TOKEN_SIZE];
20702077
const char *src0 = r_esil_pop (esil);
2071-
const char *src1 = NULL;
2072-
if (src0 && r_esil_get_parm (esil, src0, &s)) {
2073-
r_esil_push (esil, dst);
2078+
if (dst && src0 && r_esil_get_parm (esil, src0, &s)) {
2079+
r_str_ncpy (dst_buf, dst, sizeof (dst_buf));
2080+
r_esil_push (esil, dst_buf);
20742081
ret = (!!esil_peek_n (esil, bits));
2075-
src1 = r_esil_pop (esil);
2082+
const char *src1 = r_esil_pop (esil);
20762083
if (src1 && r_esil_get_parm (esil, src1, &d)) {
20772084
d >>= s;
20782085
r_esil_pushnum (esil, d);
2079-
r_esil_push (esil, dst);
2086+
r_esil_push (esil, dst_buf);
20802087
ret &= (!!esil_poke_n (esil, bits));
20812088
} else {
20822089
ret = false;

0 commit comments

Comments
 (0)