From f06e5efd2f1a2285fed225fbfca5c6dcdef7d9ae Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Mon, 21 Oct 2024 16:41:54 -0400 Subject: [PATCH] Fix uninitialized data in packing holes in BfVariant structs --- IDEHelper/Compiler/BfModule.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index f626b34a..efd274bb 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -12945,7 +12945,9 @@ BfVariant BfModule::TypedValueToVariant(BfAstNode* refNode, const BfTypedValue& } else { - BfVariant::StructData* structData = (BfVariant::StructData*)(new uint8[value.mType->mSize + 4]); + int allocSize = value.mType->mSize + 4; + BfVariant::StructData* structData = (BfVariant::StructData*)(new uint8[allocSize]); + memset(structData, 0, allocSize); structData->mSize = value.mType->mSize; mBfIRBuilder->WriteConstant(value.mValue, structData->mData, value.mType); variant.mTypeCode = BfTypeCode_Struct;