From 2606f7196ef3d0294fd707ab3db8dafd328ace60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Thu, 9 Jun 2016 09:11:44 +0200 Subject: [PATCH] SuffixRowAdapter index preconditions --- GRDB/Core/RowAdapter.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/GRDB/Core/RowAdapter.swift b/GRDB/Core/RowAdapter.swift index 6e7d94069..59a4dc4d1 100644 --- a/GRDB/Core/RowAdapter.swift +++ b/GRDB/Core/RowAdapter.swift @@ -199,11 +199,13 @@ public struct SuffixRowAdapter : RowAdapter { /// /// If index is 0, the adapted row is identical to the original row. public init(fromIndex index: Int) { + GRDBPrecondition(index >= 0, "Negative column index is out of range") self.index = index } /// Part of the RowAdapter protocol public func concreteRowAdapter(with statement: SelectStatement) throws -> ConcreteRowAdapter { + GRDBPrecondition(index <= statement.columnCount, "Column index is out of range") return AdaptedColumnsDescription(columns: statement.columnNames.suffixFrom(index).enumerate().map { ($0 + index, $1) }) } }