summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qarraydataops.h
diff options
context:
space:
mode:
authorAndrei Golubev <andrei.golubev@qt.io>2020-11-10 19:43:52 +0100
committerAndrei Golubev <andrei.golubev@qt.io>2020-11-12 09:53:49 +0100
commit405305069fc5f1a98719dbcff6a8a3cbd1714ab0 (patch)
tree386b0ec55a19c679279171fc44145c2edd802db8 /src/corelib/tools/qarraydataops.h
parent7549d1805422dad1ef1b08f25581b84fe1ce3335 (diff)
Clean realloc() related bits in QString/QBA and Q*ArrayOps
Fixed misleading naming of "slowReallocatePath". It's no longer "slow", it's downright dangerous now to reallocate under certain conditions Added several asserts which should've been there already as our code would run into a UB/crash anyhow - let's at least get extra checks that are closer to the trouble causing places Bring back the (slightly modified) code-cleaning changes from 504972f838761f79a170c22225add496e7e5af6a Change-Id: Ie1358aebc619062d3991a78049e366dc0e8c267e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/corelib/tools/qarraydataops.h')
-rw-r--r--src/corelib/tools/qarraydataops.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h
index c6ab3b1c48..d7e7b4bf07 100644
--- a/src/corelib/tools/qarraydataops.h
+++ b/src/corelib/tools/qarraydataops.h
@@ -479,6 +479,7 @@ public:
void reallocate(qsizetype alloc, QArrayData::AllocationOption option)
{
auto pair = Data::reallocateUnaligned(this->d, this->ptr, alloc, option);
+ Q_ASSERT(pair.first != nullptr);
this->d = pair.first;
this->ptr = pair.second;
}
@@ -1132,6 +1133,7 @@ public:
void reallocate(qsizetype alloc, QArrayData::AllocationOption option)
{
auto pair = Data::reallocateUnaligned(this->d, this->ptr, alloc, option);
+ Q_ASSERT(pair.first != nullptr);
this->d = pair.first;
this->ptr = pair.second;
}