Skip to content

Commit

Permalink
ppc: fix a segfault in Diet mode
Browse files Browse the repository at this point in the history
  • Loading branch information
aquynh committed Mar 4, 2014
1 parent 1cf70fe commit ca9a7ab
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions arch/PowerPC/PPCInstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,7 @@ static void printU16ImmOperand(MCInst *MI, unsigned OpNo, SStream *O)

static void printBranchOperand(MCInst *MI, unsigned OpNo, SStream *O)
{
if (!MCOperand_isImm(MCInst_getOperand(MI, OpNo)))
{
if (!MCOperand_isImm(MCInst_getOperand(MI, OpNo))) {
printOperand(MI, OpNo, O);
return;
}
Expand All @@ -384,8 +383,7 @@ static void printBranchOperand(MCInst *MI, unsigned OpNo, SStream *O)

static void printAbsBranchOperand(MCInst *MI, unsigned OpNo, SStream *O)
{
if (!MCOperand_isImm(MCInst_getOperand(MI, OpNo)))
{
if (!MCOperand_isImm(MCInst_getOperand(MI, OpNo))) {
printOperand(MI, OpNo, O);
return;
}
Expand Down Expand Up @@ -495,14 +493,18 @@ static void printOperand(MCInst *MI, unsigned OpNo, SStream *O)
MCOperand *Op = MCInst_getOperand(MI, OpNo);
if (MCOperand_isReg(Op)) {
unsigned reg = MCOperand_getReg(Op);
#ifndef CAPSTONE_DIET
const char *RegName = getRegisterName(reg);
#endif
// map to public register
reg = PPC_map_register(reg);
#ifndef CAPSTONE_DIET
// The linux and AIX assembler does not take register prefixes.
if (MI->csh->syntax == CS_OPT_SYNTAX_NOREGNAME)
RegName = stripRegisterPrefix(RegName);

SStream_concat(O, "%s", RegName);
#endif

if (MI->csh->detail) {
if (MI->csh->doing_mem) {
Expand Down

0 comments on commit ca9a7ab

Please sign in to comment.