From 981e16ad019a0f46c81d300bcc4efa5ed4cbd93c Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Fri, 26 Aug 2016 01:38:58 +0300 Subject: [PATCH] Assign the parameter index temporarily before validating to prevent exception if the currently assigned index is invalid. --- modules/sqlite/Parameter.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/sqlite/Parameter.cpp b/modules/sqlite/Parameter.cpp index 49416ade..325b6579 100644 --- a/modules/sqlite/Parameter.cpp +++ b/modules/sqlite/Parameter.cpp @@ -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); } // ------------------------------------------------------------------------------------------------