summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-03-12 15:03:16 +0100
committerMarc Mutz <marc.mutz@kdab.com>2016-03-15 10:39:20 +0000
commitadd95c55108dcda46286846dae5ad12d6ee9057b (patch)
treea734b176ad2da36c68e6c33db5adf77e35ffd441 /src/sql
parent52a599bb56e5e5e625909c25edee8487b0a3754d (diff)
tst_QSqlQuery: fix UBs (invalid downcasts, member calls)
The existing code derived a helper class from QSqlResult and overloaded two protected functions as public ones so the test could call them after casting QSqlResults to that helper class. Both the cast (which is a C-style cast, but with combined static_cast and const_cast semanics) and the following member function call are undefined behavior. Fix by making the test class a friend of QSqlResult, and dropping the casts. Change-Id: I09de2e2b46976d01cfce25892aec6ad36881d3eb Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/kernel/qsqlresult.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/sql/kernel/qsqlresult.h b/src/sql/kernel/qsqlresult.h
index c86a8f858f..eeef68d2b8 100644
--- a/src/sql/kernel/qsqlresult.h
+++ b/src/sql/kernel/qsqlresult.h
@@ -38,6 +38,9 @@
#include <QtCore/qvector.h>
#include <QtSql/qsql.h>
+// for testing:
+class tst_QSqlQuery;
+
QT_BEGIN_NAMESPACE
@@ -54,6 +57,8 @@ class Q_SQL_EXPORT QSqlResult
Q_DECLARE_PRIVATE(QSqlResult)
friend class QSqlQuery;
friend class QSqlTableModelPrivate;
+ // for testing:
+ friend class ::tst_QSqlQuery;
public:
virtual ~QSqlResult();