Corrected a bug

Corrected a bug that would cause capstone to crash under certain invalid
instructions.
This commit is contained in:
Fotis Loukos 2017-04-14 22:39:40 +03:00
parent 5fbe75eb50
commit 357828b858
1 changed files with 10 additions and 5 deletions

View File

@ -68,12 +68,17 @@ void TMS320C64x_post_printer(csh ud, cs_insn *insn, char *insn_asm, MCInst *mci)
SStream_concat0(&ss, insn_asm);
if((p != NULL) && (((p2 = strchr(p, '[')) != NULL) || ((p2 = strchr(p, '(')) != NULL))) {
while((*p2 != 'A') && (*p2 != 'B'))
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");
}
} else {
tmp[0] = '\0';
}