Skip to content

Commit

Permalink
Pointer addition opcodes must leave NULL pointers as they are.
Browse files Browse the repository at this point in the history
  • Loading branch information
Doom2fan authored and coelckers committed Aug 16, 2018
1 parent ac46263 commit a8ce626
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/scripting/vm/jit.cpp
Expand Up @@ -1461,18 +1461,38 @@ JitFuncPtr JitCompile(VMScriptFunction *sfunc)
case OP_ADDA_RR: // pA = pB + dkC
{
auto tmp = cc.newIntPtr();
Label label = cc.newLabel();

cc.mov(tmp, regA[B]);

// Check if zero, the first operand is zero, if it is, don't add.
cc.cmp(tmp, 0);
cc.je(label);

cc.add(tmp, regD[C]);

cc.bind(label);
cc.mov(regA[a], tmp);

break;
}

case OP_ADDA_RK:
{
auto tmp = cc.newIntPtr();
Label label = cc.newLabel();

cc.mov(tmp, regA[B]);

// Check if zero, the first operand is zero, if it is, don't add.
cc.cmp(tmp, 0);
cc.je(label);

cc.add(tmp, konstd[C]);

cc.bind(label);
cc.mov(regA[a], tmp);

break;
}

Expand Down

0 comments on commit a8ce626

Please sign in to comment.