Fixed containerValue allocation (mustn't allocate a new one)

This commit is contained in:
smallmodel committed 2023-08-17 03:18:19 +02:00
1 parent 73bc196592
commit a3c65ef7e4
1 file changed
+12 -9
+12 -9
View File
@@ -547,11 +547,18 @@ void ScriptVariable::ClearInternal()
m_data.constArrayValue = NULL;
break;
case VARIABLE_LISTENER:
case VARIABLE_LISTENER:
if (m_data.listenerValue) {
delete m_data.listenerValue;
m_data.listenerValue = NULL;
}
break;
case VARIABLE_SAFECONTAINER:
if (m_data.listenerValue) {
delete m_data.listenerValue;
m_data.listenerValue = NULL;
if (m_data.safeContainerValue) {
delete m_data.safeContainerValue;
m_data.safeContainerValue = NULL;
}
break;
@@ -970,7 +977,7 @@ void ScriptVariable::evalArrayAt(ScriptVariable& var)
case VARIABLE_CONTAINER:
index = var.intValue();
if (!index || index > m_data.constArrayValue->size) {
if (!index || index > m_data.containerValue->NumObjects()) {
throw ScriptException("array index %d out of range", index);
}
@@ -2053,10 +2060,6 @@ ScriptVariable& ScriptVariable::operator=(const ScriptVariable& variable)
m_data.constArrayValue->refCount++;
break;
case VARIABLE_CONTAINER:
m_data.containerValue = new Container<SafePtr<Listener>>(*variable.m_data.containerValue);
break;
case VARIABLE_SAFECONTAINER:
m_data.safeContainerValue = new SafePtr<ConList>(*variable.m_data.safeContainerValue);
break;