Skip to content

Commit

Permalink
Merge pull request capstone-engine#2028 from Rot127/set_cr0_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kabeor authored May 22, 2023
2 parents dc69f00 + d3fc2da commit 80ede42
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions arch/PowerPC/PPCInstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ void PPC_printInst(MCInst *MI, SStream *O, void *Info)
{
char *mnem;
unsigned int opcode = MCInst_getOpcode(MI);
memset(O->buffer, 0, sizeof(O->buffer));

// printf("opcode = %u\n", opcode);

Expand Down Expand Up @@ -635,6 +636,16 @@ void PPC_printInst(MCInst *MI, SStream *O, void *Info)
cs_mem_free(mnem);
} else
printInstruction(MI, O);

const char *mnem_end = strchr(O->buffer, ' ');
unsigned mnem_len = 0;
if (mnem_end)
mnem_len = mnem_end - O->buffer;
if (!mnem_end || mnem_len >= sizeof(MI->flat_insn->mnemonic))
mnem_len = sizeof(MI->flat_insn->mnemonic) - 1;

memset(MI->flat_insn->mnemonic, 0, sizeof(MI->flat_insn->mnemonic));
strncpy(MI->flat_insn->mnemonic, O->buffer, mnem_len);
}

// FIXME
Expand Down

0 comments on commit 80ede42

Please sign in to comment.