From c581d11eba0885d3e286d58cf648fec52caf6cd4 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Thu, 22 Jul 2021 14:04:39 -0700 Subject: [PATCH] [set] in hb_set_set() avoid calling memcpy on nullptr. --- src/hb-set.hh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hb-set.hh b/src/hb-set.hh index 4356a81c4..d58ecf8ac 100644 --- a/src/hb-set.hh +++ b/src/hb-set.hh @@ -488,6 +488,11 @@ struct hb_set_t if (!resize (count)) return; population = other.population; + + if (!count) + // memcpy is not necessary if the vectors are zero length. This avoids possibly + // passing nullptr to memcpy. + return; memcpy ((void *) pages, (const void *) other.pages, count * pages.item_size); memcpy ((void *) page_map, (const void *) other.page_map, count * page_map.item_size); }