QVarLengthArray: protect against aliasing in resize(n, t)
Amends a00a1d8806cfbf17e04b88d1b4ff4a9cf5b6294a. Change-Id: I3fa6183466715555530d4042006049e286897343 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 0cfaa6e8964a0458cca20ce686b6a399293ad4cc) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
e5598520b4
commit
43a43e1377
@ -218,6 +218,10 @@ protected:
|
||||
void reallocate_impl(qsizetype prealloc, void *array, qsizetype size, qsizetype alloc);
|
||||
void resize_impl(qsizetype prealloc, void *array, qsizetype sz, const T &v)
|
||||
{
|
||||
if (QtPrivate::q_points_into_range(&v, begin(), end())) {
|
||||
resize_impl(prealloc, array, sz, T(v));
|
||||
return;
|
||||
}
|
||||
reallocate_impl(prealloc, array, sz, qMax(sz, capacity()));
|
||||
while (size() < sz) {
|
||||
q20::construct_at(data() + size(), v);
|
||||
|
Loading…
x
Reference in New Issue
Block a user