aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/ftw
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-06-26 11:00:56 +0200
committerMarc Mutz <marc.mutz@qt.io>2023-06-26 16:23:23 +0200
commit7381110745572478ffa3c68000574bc4ccb2396c (patch)
tree966d3f44ad04e5e371b341747c27be78eec29b6d /src/qml/qml/ftw
parenta2541c30988b0e560c7eab27ba85d1771550263a (diff)
QRecyclePool: fix potential UB
Return the pointer returned by placement new, not the pointer used as input to placement new. There is a subtle difference and this grey zone of the C++ standard is best avoided (keyword: std::launder()). Pick-to: 6.6 6.5 6.2 5.15 Change-Id: I27c159cdb29a5837120f3d44aa6c95da040fd1a2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/qml/ftw')
-rw-r--r--src/qml/qml/ftw/qrecyclepool_p.h9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/qml/qml/ftw/qrecyclepool_p.h b/src/qml/qml/ftw/qrecyclepool_p.h
index 6c2b22d93b..c27cc63d9a 100644
--- a/src/qml/qml/ftw/qrecyclepool_p.h
+++ b/src/qml/qml/ftw/qrecyclepool_p.h
@@ -96,8 +96,7 @@ template<typename T, int Step>
T *QRecyclePool<T, Step>::New()
{
T *rv = d->allocate();
- new (rv) T;
- return rv;
+ return new (rv) T;
}
template<typename T, int Step>
@@ -105,8 +104,7 @@ template<typename T1>
T *QRecyclePool<T, Step>::New(const T1 &a)
{
T *rv = d->allocate();
- new (rv) T(a);
- return rv;
+ return new (rv) T(a);
}
template<typename T, int Step>
@@ -114,8 +112,7 @@ template<typename T1>
T *QRecyclePool<T, Step>::New(T1 &a)
{
T *rv = d->allocate();
- new (rv) T(a);
- return rv;
+ return new (rv) T(a);
}
template<typename T, int Step>