From 1d832693e17935e025201905236b9fa34e1f310d Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 19 Aug 2021 16:02:30 -0600 Subject: [PATCH] [set] Protect against immutible null set with invertible addition --- src/hb-map.cc | 2 ++ src/hb-set.cc | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/hb-map.cc b/src/hb-map.cc index 6757535b7..388e67886 100644 --- a/src/hb-map.cc +++ b/src/hb-map.cc @@ -188,6 +188,7 @@ hb_map_set (hb_map_t *map, hb_codepoint_t key, hb_codepoint_t value) { + /* Immutable-safe. */ map->set (key, value); } @@ -220,6 +221,7 @@ void hb_map_del (hb_map_t *map, hb_codepoint_t key) { + /* Immutable-safe. */ map->del (key); } diff --git a/src/hb-set.cc b/src/hb-set.cc index eb6f41e11..f9bc85869 100644 --- a/src/hb-set.cc +++ b/src/hb-set.cc @@ -254,6 +254,7 @@ void hb_set_add (hb_set_t *set, hb_codepoint_t codepoint) { + /* Immutible-safe. */ set->add (codepoint); } @@ -273,6 +274,7 @@ hb_set_add_range (hb_set_t *set, hb_codepoint_t first, hb_codepoint_t last) { + /* Immutible-safe. */ set->add_range (first, last); } @@ -289,6 +291,7 @@ void hb_set_del (hb_set_t *set, hb_codepoint_t codepoint) { + /* Immutible-safe. */ set->del (codepoint); } @@ -311,6 +314,7 @@ hb_set_del_range (hb_set_t *set, hb_codepoint_t first, hb_codepoint_t last) { + /* Immutible-safe. */ set->del_range (first, last); } @@ -364,6 +368,9 @@ void hb_set_set (hb_set_t *set, const hb_set_t *other) { + if (unlikely (hb_object_is_immutable (set))) + return; + set->set (*other); } @@ -380,6 +387,9 @@ void hb_set_union (hb_set_t *set, const hb_set_t *other) { + if (unlikely (hb_object_is_immutable (set))) + return; + set->union_ (*other); } @@ -396,6 +406,9 @@ void hb_set_intersect (hb_set_t *set, const hb_set_t *other) { + if (unlikely (hb_object_is_immutable (set))) + return; + set->intersect (*other); } @@ -412,6 +425,9 @@ void hb_set_subtract (hb_set_t *set, const hb_set_t *other) { + if (unlikely (hb_object_is_immutable (set))) + return; + set->subtract (*other); } @@ -429,6 +445,9 @@ void hb_set_symmetric_difference (hb_set_t *set, const hb_set_t *other) { + if (unlikely (hb_object_is_immutable (set))) + return; + set->symmetric_difference (*other); } @@ -443,6 +462,9 @@ hb_set_symmetric_difference (hb_set_t *set, void hb_set_invert (hb_set_t *set) { + if (unlikely (hb_object_is_immutable (set))) + return; + set->invert (); }