diff --git a/include/gfx/bitmap.c b/include/gfx/bitmap.c index 07f7166..516db92 100644 --- a/include/gfx/bitmap.c +++ b/include/gfx/bitmap.c @@ -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) { diff --git a/oscar64/Errors.h b/oscar64/Errors.h index f824e15..24d9f73 100644 --- a/oscar64/Errors.h +++ b/oscar64/Errors.h @@ -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, diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index 79c3608..1999929 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -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); diff --git a/oscar64/NativeCodeGenerator.h b/oscar64/NativeCodeGenerator.h index 397bd28..9cb807a 100644 --- a/oscar64/NativeCodeGenerator.h +++ b/oscar64/NativeCodeGenerator.h @@ -210,9 +210,10 @@ public: class NativeCodeBasicBlock { public: - NativeCodeBasicBlock(void); + NativeCodeBasicBlock(NativeCodeProcedure * proc); ~NativeCodeBasicBlock(void); + NativeCodeProcedure * mProc; ExpandingArray mCode; ExpandingArray mCodeLocations;