Skip to content

Commit

Permalink
arm: fix a memory leaking bug
Browse files Browse the repository at this point in the history
  • Loading branch information
aquynh committed Dec 4, 2013
1 parent da8adad commit 39da426
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions MCInst.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ void MCInst_clear(MCInst *inst)
inst->size = 0;
}

// NOTE: this will free @Op argument
void MCInst_insert(MCInst *inst, int index, MCOperand *Op)
{
int i;
Expand All @@ -28,6 +29,8 @@ void MCInst_insert(MCInst *inst, int index, MCOperand *Op)

inst->Operands[index] = *Op;
inst->size++;

free(Op);
}

void MCInst_setOpcode(MCInst *inst, unsigned Op)
Expand Down Expand Up @@ -60,6 +63,7 @@ unsigned MCInst_getNumOperands(const MCInst *inst)
return inst->size;
}

// NOTE: this will free @Op argument
int MCInst_addOperand(MCInst *inst, MCOperand *Op)
{
if (inst->size == ARR_SIZE(inst->Operands))
Expand Down

0 comments on commit 39da426

Please sign in to comment.