1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Assign the parameter index temporarily before validating to prevent exception if the currently assigned index is invalid.

This commit is contained in:
Sandu Liviu Catalin 2016-08-26 01:38:58 +03:00
parent 5136a93d37
commit 981e16ad01

View File

@ -223,10 +223,12 @@ void Parameter::SetIndex(const Object & param)
// We don't recognize this kind of value!
default: STHROWF("Unknown parameter index of type (%s)", SqTypeName(param.GetType()));
}
// Assign the index with a failsafe to invalid on error
AutoAssign< Int32 > aa(m_Index, 0, idx);
// Validate the obtained parameter index
SQMOD_VALIDATE_PARAM(*this, idx);
// Assign the new index
m_Index = idx;
// Don't fall back to the invalid index anymore
aa.Set(idx);
}
// ------------------------------------------------------------------------------------------------