From 2c1f588cbae2b048789d2ec5bc9727905ab75995 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Thu, 25 Aug 2016 11:55:20 +0300 Subject: [PATCH] Assign the column index temporarily before validating to prevent exception if the currently assigned index is invalid. --- modules/sqlite/Column.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/sqlite/Column.cpp b/modules/sqlite/Column.cpp index 44b0c762..6f8b105b 100644 --- a/modules/sqlite/Column.cpp +++ b/modules/sqlite/Column.cpp @@ -241,10 +241,12 @@ void Column::SetIndex(const Object & column) // We don't recognize this kind of value! default: STHROWF("Unknown column index of type (%s)", SqTypeName(column.GetType())); } + // Assign the index with a failsafe to invalid on error + AutoAssign< Int32 > aa(m_Index, -1, idx); // Validate the obtained column index SQMOD_VALIDATE_COLUMN(*this, idx); - // Assign the new index - m_Index = idx; + // Don't fall back to the invalid index anymore + aa.Set(idx); } // ------------------------------------------------------------------------------------------------