diff --git a/IDEHelper/Compiler/BfCompiler.cpp b/IDEHelper/Compiler/BfCompiler.cpp index e7ae1368..9dac7752 100644 --- a/IDEHelper/Compiler/BfCompiler.cpp +++ b/IDEHelper/Compiler/BfCompiler.cpp @@ -10353,6 +10353,10 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo emitParser->GetLineCharAtIdx(kv.mValue.mSrcStart, startLine, startLineChar); int srcEnd = kv.mValue.mSrcEnd - 1; + + if (srcEnd >= emitParser->mOrigSrcLength) + continue; + while (srcEnd >= kv.mValue.mSrcStart) { char c = emitParser->mSrc[srcEnd]; diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index 2310cc04..bf3e7156 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -4235,19 +4235,22 @@ void BfModule::CreateStaticField(BfFieldInstance* fieldInstance, bool isThreadLo else irType = mBfIRBuilder->MapType(fieldType, BfIRPopulateType_Eventually_Full); - BfIRValue globalVar = mBfIRBuilder->CreateGlobalVariable( - irType, - false, - BfIRLinkageType_External, - initValue, - staticVarName, - isThreadLocal); - mBfIRBuilder->GlobalVar_SetAlignment(globalVar, fieldType->mAlign); - if (storageKind != BfIRStorageKind_Normal) - mBfIRBuilder->GlobalVar_SetStorageKind(globalVar, storageKind); + if (fieldType->mSize > 0) + { + BfIRValue globalVar = mBfIRBuilder->CreateGlobalVariable( + irType, + false, + BfIRLinkageType_External, + initValue, + staticVarName, + isThreadLocal); + mBfIRBuilder->GlobalVar_SetAlignment(globalVar, fieldType->mAlign); + if (storageKind != BfIRStorageKind_Normal) + mBfIRBuilder->GlobalVar_SetStorageKind(globalVar, storageKind); - BF_ASSERT(globalVar); - mStaticFieldRefs[fieldInstance] = globalVar; + BF_ASSERT(globalVar); + mStaticFieldRefs[fieldInstance] = globalVar; + } } } } @@ -14755,6 +14758,15 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM } else { + if (methodDef->mIdx >= typeInst->mMethodInstanceGroups.mSize) + PopulateType(typeInst, BfPopulateType_DataAndMethods); + + if (methodDef->mIdx >= typeInst->mMethodInstanceGroups.mSize) + { + InternalError("GetMethodInstance OOB error", methodDef->GetRefNode()); + return BfModuleMethodInstance(); + } + methodInstGroup = &typeInst->mMethodInstanceGroups[methodDef->mIdx]; }