From 6855b80eae71d8339b2b5d6d45b71f2306293584 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 29 Nov 2021 10:02:17 -0800 Subject: QList::count(T): remove the &* hack on iterators Use data() and data() + size() instead. This solves an UB when the list is in its default-constructed state, for which constData() == nullptr. Pick-to: 6.2 Fixes: QTBUG-98770 Change-Id: I2cffe62afda945079b63fffd16bc165978c769f6 Reviewed-by: Marc Mutz --- src/corelib/tools/qlist.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib/tools/qlist.h') diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 9b2a56a66a..5f6b77e8ce 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -585,7 +585,7 @@ public: template qsizetype count(const AT &t) const noexcept { - return qsizetype(std::count(&*cbegin(), &*cend(), t)); + return qsizetype(std::count(data(), data() + size(), t)); } void removeAt(qsizetype i) { remove(i); } -- cgit v1.2.3