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) }) } }