1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-13 05:44:11 +02:00

Fixed tyoe population stack overflow issue with some invalid base typerefs

This commit is contained in:
Brian Fiete 2021-07-16 08:09:27 -07:00
parent b017ccc2e1
commit 70da0856a7

View file

@ -2781,6 +2781,12 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
AssertErrorState(); AssertErrorState();
typeInstance->mTypeFailed = true; typeInstance->mTypeFailed = true;
} }
if (_CheckTypeDone())
{
prevDefineState.CancelRestore();
return;
}
} }
// Incase we had re-entry, work this through ourselves again here // Incase we had re-entry, work this through ourselves again here
@ -3022,9 +3028,12 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
baseType = ResolveTypeDef(mCompiler->mFunctionTypeDef)->ToTypeInstance(); baseType = ResolveTypeDef(mCompiler->mFunctionTypeDef)->ToTypeInstance();
} }
else else
{ {
for (auto checkTypeRef : typeDef->mBaseTypes) for (auto checkTypeRef : typeDef->mBaseTypes)
{ {
if ((typeInstance->mDefineState == BfTypeDefineState_ResolvingBaseType) && (typeInstance->mTypeFailed))
break;
auto declTypeDef = typeDef; auto declTypeDef = typeDef;
if (typeDef->mIsCombinedPartial) if (typeDef->mIsCombinedPartial)
declTypeDef = typeDef->mPartials.front(); declTypeDef = typeDef->mPartials.front();
@ -3032,8 +3041,9 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
SetAndRestoreValue<BfTypeReference*> prevTypeRef(mContext->mCurTypeState->mCurBaseTypeRef, checkTypeRef); SetAndRestoreValue<BfTypeReference*> prevTypeRef(mContext->mCurTypeState->mCurBaseTypeRef, checkTypeRef);
SetAndRestoreValue<BfTypeDefineState> prevDefineState(typeInstance->mDefineState, BfTypeDefineState_ResolvingBaseType); SetAndRestoreValue<BfTypeDefineState> prevDefineState(typeInstance->mDefineState, BfTypeDefineState_ResolvingBaseType);
bool populateBase = !typeInstance->mTypeFailed; bool populateBase = !typeInstance->mTypeFailed;
auto checkType = ResolveTypeRef(checkTypeRef, BfPopulateType_Declaration); BfType* checkType = checkType = ResolveTypeRef(checkTypeRef, BfPopulateType_Declaration);
if ((checkType != NULL) && (!checkType->IsInterface()) && (populateBase)) if ((checkType != NULL) && (!checkType->IsInterface()) && (populateBase))
{ {
SetAndRestoreValue<BfTypeInstance*> prevBaseType(mContext->mCurTypeState->mCurBaseType, checkType->ToTypeInstance()); SetAndRestoreValue<BfTypeInstance*> prevBaseType(mContext->mCurTypeState->mCurBaseType, checkType->ToTypeInstance());
@ -3138,6 +3148,12 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
} }
} }
} }
if (_CheckTypeDone())
{
prevDefineState.CancelRestore();
return;
}
} }
else else
{ {
@ -3150,6 +3166,9 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
wantPopulateInterfaces = true; wantPopulateInterfaces = true;
} }
if (_CheckTypeDone())
return;
if (resolvedTypeRef->IsBoxed()) if (resolvedTypeRef->IsBoxed())
{ {
if ((baseType != NULL) && (baseType->IsStruct())) if ((baseType != NULL) && (baseType->IsStruct()))