summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-07-14 12:56:27 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-07-31 20:08:50 +0200
commit0c53f8ba98fee41d84362b44eb731ff722c8f7fe (patch)
tree7b46fbac2915998a676c32d172fc11c35fbdaf75 /src/corelib/tools
parent797e18118bc74597f1211e993f58451aaa6f081c (diff)
Fix undefined use of memcpy and memcmp
Don't call them on a nullptr, even with a length of 0. Change-Id: I7fee23303562e5771697a16365cae12e3e87af6f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qhash.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index eacc373ee3..2b1b155efb 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -397,7 +397,8 @@ struct Span {
// we only add storage if the previous storage was fully filled, so
// simply copy the old data over
if constexpr (isRelocatable<Node>()) {
- memcpy(newEntries, entries, allocated*sizeof(Entry));
+ if (allocated)
+ memcpy(newEntries, entries, allocated*sizeof(Entry));
} else {
for (size_t i = 0; i < allocated; ++i) {
new (&newEntries[i].node()) Node(std::move(entries[i].node()));