summaryrefslogtreecommitdiffstats
path: root/src/sql/models/qsqlquerymodel.cpp
diff options
context:
space:
mode:
authorHonglei Zhang <honglei.zhang@nokia.com>2012-03-07 18:54:58 +0200
committerQt by Nokia <qt-info@nokia.com>2012-03-30 19:51:43 +0200
commit06001ce0085c5fd47bbcc3c7ab151f7c0ac2f0ed (patch)
treeb1f2949df1825048a247ed3f91a994a188eb3dc2 /src/sql/models/qsqlquerymodel.cpp
parentfa9cf676159e8d9876c8532dc4e90f4bf5d9a47b (diff)
Fix crash when an invalid filter is set
QSqlTableModel::headerData() generates a crash if an invalid filter is set. QSqlQueryModel::indexInQuery() should check the index value before applied to d->colOffsets[]. QSqlQueryModel::initRecordAndPrimaryIndex() is updated to sync the size of rec and colOffsets. Task-number: QTBUG-23879 Change-Id: Ic9f88bb288592aa6fb3c1415cc818632dadaab56 Reviewed-by: Michael Goddard <michael.goddard@nokia.com> Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Diffstat (limited to 'src/sql/models/qsqlquerymodel.cpp')
-rw-r--r--src/sql/models/qsqlquerymodel.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/sql/models/qsqlquerymodel.cpp b/src/sql/models/qsqlquerymodel.cpp
index 341804f1ae..fefb87dcf5 100644
--- a/src/sql/models/qsqlquerymodel.cpp
+++ b/src/sql/models/qsqlquerymodel.cpp
@@ -591,7 +591,8 @@ QModelIndex QSqlQueryModel::indexInQuery(const QModelIndex &item) const
{
Q_D(const QSqlQueryModel);
if (item.column() < 0 || item.column() >= d->rec.count()
- || !d->rec.isGenerated(item.column()))
+ || !d->rec.isGenerated(item.column())
+ || item.column() >= d->colOffsets.size())
return QModelIndex();
return createIndex(item.row(), item.column() - d->colOffsets[item.column()],
item.internalPointer());