From 07b92234ad4970db35fba34daad58a1105229225 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 3 Oct 2022 21:48:57 -0500 Subject: [PATCH] Fix bug for python SDL variable-length arrays --- Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp b/Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp index 6d008ce7..1080d5e7 100644 --- a/Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/plPythonSDLModifier.cpp @@ -474,6 +474,12 @@ void plPythonSDLModifier::IPythonVarToSDL(plStateDataRecord* state, const char* int count = PyTuple_Size(pyVar); plSimpleVarDescriptor::Type type = var->GetSimpleVarDescriptor()->GetType(); + // Ensure that variable length arrays match. + if (var->GetSimpleVarDescriptor()->IsVariableLength()) { + if (var->GetCount() != count) + var->Alloc(count); + } + for (int i = 0; i < count; i++) { PyObject* pyVarItem = PyTuple_GetItem(pyVar, i);