[set] in hb_set_set() avoid calling memcpy on nullptr.

This commit is contained in:
Garret Rieger 2021-07-22 14:04:39 -07:00
parent 2b9cb29923
commit c581d11eba
1 changed files with 5 additions and 0 deletions

View File

@ -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);
}