radare2/shlr/capstone-patches/fix-underflow-tms.patch

29 lines
888 B
Diff

diff --git a/arch/TMS320C64x/TMS320C64xInstPrinter.c b/arch/TMS320C64x/TMS320C64xInstPrinter.c
index fa57893..d6e9896 100644
--- a/arch/TMS320C64x/TMS320C64xInstPrinter.c
+++ b/arch/TMS320C64x/TMS320C64xInstPrinter.c
@@ -70,15 +70,14 @@ void TMS320C64x_post_printer(csh ud, cs_insn *insn, char *insn_asm, MCInst *mci)
if((p != NULL) && (((p2 = strchr(p, '[')) != NULL) || ((p2 = strchr(p, '(')) != NULL))) {
while((p2 > p) && ((*p2 != 'A') && (*p2 != 'B')))
p2--;
- if(p2 == p) {
- strcpy(insn_asm, "Invalid!");
- return;
- } else {
- if(*p2 == 'A')
- strcpy(tmp, "1T");
- else
- strcpy(tmp, "2T");
- }
+ if(p2 <= p) {
+ strcpy(insn_asm, "Invalid!");
+ return;
+ }
+ if(*p2 == 'A')
+ strcpy(tmp, "1T");
+ else
+ strcpy(tmp, "2T");
} else {
tmp[0] = '\0';
}