summaryrefslogtreecommitdiffstats
path: root/src/plugins/sqldrivers/odbc
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2024-02-08 17:22:57 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2024-02-29 00:12:43 +0100
commit6287daaa20bfb306d1e2d87d67df961e1da2857a (patch)
tree6d3fa7785ee7ca1fe3295caceb3a8fdc09c0be2e /src/plugins/sqldrivers/odbc
parent3fc1adcda5fc64a92bf5f5016fc276545105887e (diff)
SQL/ODBC: Don't assert when no error record is available
When SQLGetDiagRec() does not return an record, the list of DiagRecords might be empty. This will create an assertion when trying to access QList::front() or similar. Therefore we need to check if the list is empty before accessing it. This amends 4ec5c0efc756a39162b43367438fee965c229ae7 Fixes: QTBUG-122073 Pick-to: 6.7 6.6 Change-Id: I6f421d82f9b6fdf84672d755cbbe8d2adec13266 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/plugins/sqldrivers/odbc')
-rw-r--r--src/plugins/sqldrivers/odbc/qsql_odbc.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
index 781551ca50..3a325abad6 100644
--- a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
+++ b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
@@ -269,6 +269,8 @@ static DiagRecord combineRecords(const QList<DiagRecord> &records)
a.sqlState + u';' + b.sqlState,
a.errorCode + u';' + b.errorCode};
};
+ if (records.isEmpty())
+ return {};
return std::accumulate(std::next(records.begin()), records.end(), records.front(), add);
}