From 0c53f8ba98fee41d84362b44eb731ff722c8f7fe Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 14 Jul 2020 12:56:27 +0200 Subject: 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 --- src/corelib/tools/qhash.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/corelib/tools') 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()) { - 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())); -- cgit v1.2.3