From a14544efa646b4c48100f05b82f9e77cf2ec0eb7 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Tue, 5 Jan 2021 16:23:49 -0800 Subject: [PATCH] Fixed potential non-const cast of array size in type lookup --- IDEHelper/Compiler/BfResolvedTypeUtils.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/IDEHelper/Compiler/BfResolvedTypeUtils.cpp b/IDEHelper/Compiler/BfResolvedTypeUtils.cpp index a53a0b5d..76c0e4fd 100644 --- a/IDEHelper/Compiler/BfResolvedTypeUtils.cpp +++ b/IDEHelper/Compiler/BfResolvedTypeUtils.cpp @@ -3171,10 +3171,14 @@ int BfResolvedTypeSet::Hash(BfTypeReference* typeRef, LookupContext* ctx, BfHash hashVal = ((hashVal ^ elemHash) << 5) - hashVal; return hashVal; } - if (!typedVal) + if (!typedVal) ctx->mFailed = true; if (typedVal) + { + SetAndRestoreValue prevIgnoreWrites(ctx->mModule->mBfIRBuilder->mIgnoreWrites, true); typedVal = ctx->mModule->Cast(sizeExpr, typedVal, intType); + } + if (typedVal) { auto constant = ctx->mModule->mBfIRBuilder->GetConstant(typedVal.mValue);