diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-09-24 10:37:22 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-09-30 00:10:40 +0200 |
commit | 0c07f0cab8da55a9889186749f7419a790595a7b (patch) | |
tree | 2d16590bcf7c883fc4150da4662525870d524352 /src/corelib/tools/qarraydataops.h | |
parent | e4fece60aaef43e8a8139c16b276f76e22d3cc9d (diff) |
Fix ubsan errors
Nullptr memcpy, memmove and 36 bit shift of integer.
Change-Id: Ib79c8a98a710d021fc93b6aaec6c0ba9bde5f91e
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qarraydataops.h')
-rw-r--r-- | src/corelib/tools/qarraydataops.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index 1d7e307192..b0834ad762 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -1367,6 +1367,8 @@ public: Q_ASSERT(!this->isShared() || b == e); Q_ASSERT(b <= e); Q_ASSERT(size_t(e - b) <= this->allocatedCapacity() - this->size); + if (b == e) // short-cut and handling the case b and e == nullptr + return; prepareSpaceForAppend(b, e, e - b); // ### perf. loss Base::insert(GrowsForwardTag{}, this->end(), b, e); @@ -1397,6 +1399,8 @@ public: Q_ASSERT(!this->isShared() || b == e); Q_ASSERT(b <= e); Q_ASSERT(size_t(e - b) <= this->allocatedCapacity() - this->size); + if (b == e) // short-cut and handling the case b and e == nullptr + return; prepareSpaceForAppend(b, e, e - b); // ### perf. loss Base::moveAppend(b, e); @@ -1421,6 +1425,8 @@ public: Q_ASSERT(b <= e); Q_ASSERT(e <= where || b > this->end() || where == this->end()); // No overlap or append Q_ASSERT(size_t(e - b) <= this->allocatedCapacity() - this->size); + if (b == e) // short-cut and handling the case b and e == nullptr + return; if (this->size > 0 && where == this->begin()) { // prepend case - special space arrangement prepareSpaceForPrepend(b, e, e - b); // ### perf. loss |