From 1eb67b25d3a2a3e70c86f631bd59c858d69acd4f Mon Sep 17 00:00:00 2001 From: sshutina Date: Mon, 14 Jul 2025 11:04:03 +0100 Subject: [PATCH] Data Exchange, GLTF Reader - Fix indices during parsering of arrays (#602) - Use the loop index (`anIndex` or `i`) instead of always reading `theValue[0]`. - Preserve existing behavior of array allocation and string concatenation. - Updated three loops in `RWGltf_GltfJsonParser.cxx` to reference the correct element. --- src/RWGltf/RWGltf_GltfJsonParser.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/RWGltf/RWGltf_GltfJsonParser.cxx b/src/RWGltf/RWGltf_GltfJsonParser.cxx index 292cadbd48..b8174c7709 100644 --- a/src/RWGltf/RWGltf_GltfJsonParser.cxx +++ b/src/RWGltf/RWGltf_GltfJsonParser.cxx @@ -274,7 +274,8 @@ bool RWGltf_ExtrasParser::parseArray(const RWGltf_JsonValue& theValue, Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(0, theValue.Size()); for (size_t anIndex = 0; anIndex < theValue.Size(); ++anIndex) { - anArray->SetValue(static_cast(anIndex), theValue[0].GetInt()); + anArray->SetValue(static_cast(anIndex), + theValue[static_cast(anIndex)].GetInt()); } getResult()->SetArrayOfIntegers(theValueName.c_str(), anArray); return true; @@ -285,7 +286,8 @@ bool RWGltf_ExtrasParser::parseArray(const RWGltf_JsonValue& theValue, Handle(TColStd_HArray1OfReal) anArray = new TColStd_HArray1OfReal(0, theValue.Size()); for (size_t anIndex = 0; anIndex < theValue.Size(); ++anIndex) { - anArray->SetValue(static_cast(anIndex), theValue[0].GetDouble()); + anArray->SetValue(static_cast(anIndex), + theValue[static_cast(anIndex)].GetDouble()); } getResult()->SetArrayOfReals(theValueName.c_str(), anArray); return true; @@ -300,7 +302,8 @@ bool RWGltf_ExtrasParser::parseArray(const RWGltf_JsonValue& theValue, const std::string aSeparator = ";"; for (size_t i = 0; i < theValue.Size(); ++i) { - anArrayString = anArrayString + aSeparator + theValue[0].GetString(); + anArrayString = + anArrayString + aSeparator + theValue[static_cast(i)].GetString(); } getResult()->SetString(theValueName.c_str(), anArrayString.c_str()); return true; -- 2.39.5