From 3503252e12a26499dedaaa63e3efb3e431bf610b Mon Sep 17 00:00:00 2001 From: Malcolm Tyrrell Date: Tue, 16 Mar 2021 11:47:19 +0000 Subject: [PATCH] Strict check for accessor "count" --- code/AssetLib/glTF2/glTF2Asset.inl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/code/AssetLib/glTF2/glTF2Asset.inl b/code/AssetLib/glTF2/glTF2Asset.inl index daac549e9..231637e8e 100644 --- a/code/AssetLib/glTF2/glTF2Asset.inl +++ b/code/AssetLib/glTF2/glTF2Asset.inl @@ -883,7 +883,14 @@ inline void Accessor::Read(Value &obj, Asset &r) { byteOffset = MemberOrDefault(obj, "byteOffset", size_t(0)); componentType = MemberOrDefault(obj, "componentType", ComponentType_BYTE); - count = MemberOrDefault(obj, "count", size_t(0)); + { + const Value* countValue = FindUInt(obj, "count"); + if (!countValue || countValue->GetInt() < 1) + { + throw DeadlyImportError("A strictly positive count value is required, when reading ", id.c_str(), name.empty() ? "" : " (" + name + ")"); + } + count = countValue->GetUint(); + } const char *typestr; type = ReadMember(obj, "type", typestr) ? AttribType::FromString(typestr) : AttribType::SCALAR;