Fix nullptr reference cause assert in linux

This commit is contained in:
drmortalwombat 2023-06-18 09:24:50 +02:00
parent 95afe011c8
commit b8478348ed
4 changed files with 13 additions and 7 deletions

View File

@ -1164,8 +1164,8 @@ void bmu_bitblit(const Bitmap * dbm, int dx, int dy, const Bitmap * sbm, int sx,
if (op & BLIT_SRC)
{
if (!pattern)
pattern = sp;
if (!pat)
pat = sp;
if (reverse)
{

View File

@ -27,6 +27,7 @@ enum ErrorID
EWARN_USE_OF_UNINITIALIZED_VARIABLE,
EWARN_MISSING_RETURN_STATEMENT,
EWARN_UNREACHABLE_CODE,
EWARN_NULL_POINTER_DEREFERENCED,
EERR_GENERIC = 3000,
EERR_FILE_NOT_FOUND,

View File

@ -4541,7 +4541,8 @@ void NativeCodeInstruction::Assemble(NativeCodeBasicBlock* block)
}
else
{
assert(mAddress != 0);
if (mAddress == 0)
block->mProc->mGenerator->mErrors->Error(mIns->mLocation, EWARN_NULL_POINTER_DEREFERENCED, "nullptr dereferenced");
block->PutByte(uint8(mAddress));
}
break;
@ -4608,6 +4609,8 @@ void NativeCodeInstruction::Assemble(NativeCodeBasicBlock* block)
}
else
{
if (mAddress == 0)
block->mProc->mGenerator->mErrors->Error(mIns->mLocation, EWARN_NULL_POINTER_DEREFERENCED, "nullptr dereferenced");
block->PutWord(uint16(mAddress));
}
break;
@ -39601,8 +39604,9 @@ void NativeCodeBasicBlock::CopyCode(NativeCodeProcedure * proc, uint8* target)
}
}
NativeCodeBasicBlock::NativeCodeBasicBlock(void)
NativeCodeBasicBlock::NativeCodeBasicBlock(NativeCodeProcedure* proc)
{
mProc = proc;
mBranch = ASMIT_RTS;
mBranchIns = nullptr;
mTrueJump = mFalseJump = NULL;
@ -41209,7 +41213,7 @@ void NativeCodeProcedure::BuildDataFlowSets(void)
NativeCodeBasicBlock* NativeCodeProcedure::AllocateBlock(void)
{
NativeCodeBasicBlock* block = new NativeCodeBasicBlock();
NativeCodeBasicBlock* block = new NativeCodeBasicBlock(this);
block->mNoFrame = mNoFrame;
block->mFrameOffset = mFrameOffset;
block->mIndex = mTempBlocks++;
@ -41223,7 +41227,7 @@ NativeCodeBasicBlock* NativeCodeProcedure::CompileBlock(InterCodeProcedure* ipro
if (tblocks[sblock->mIndex])
return tblocks[sblock->mIndex];
NativeCodeBasicBlock* block = new NativeCodeBasicBlock();
NativeCodeBasicBlock* block = new NativeCodeBasicBlock(this);
block->mNoFrame = mNoFrame;
block->mFrameOffset = mFrameOffset;
mBlocks.Push(block);

View File

@ -210,9 +210,10 @@ public:
class NativeCodeBasicBlock
{
public:
NativeCodeBasicBlock(void);
NativeCodeBasicBlock(NativeCodeProcedure * proc);
~NativeCodeBasicBlock(void);
NativeCodeProcedure * mProc;
ExpandingArray<uint8> mCode;
ExpandingArray<CodeLocation> mCodeLocations;