From: Behdad Esfahbod Date: Wed, 3 Apr 2019 03:17:27 +0000 (-0700) Subject: [map] Protect more against pointer deref X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=31c1a83899147310b27bd40fac755c629cb59cef;p=platform%2Fupstream%2FlibHarfBuzzSharp.git [map] Protect more against pointer deref --- diff --git a/src/hb-map.hh b/src/hb-map.hh index 9883c0d..834a994 100644 --- a/src/hb-map.hh +++ b/src/hb-map.hh @@ -63,6 +63,7 @@ struct hb_hashmap_t bool operator == (const item_t &o) { return *this == o.key; } bool is_unused () const { return key == kINVALID; } bool is_tombstone () const { return key != kINVALID && value == vINVALID; } + bool is_real () const { return key != kINVALID && value != vINVALID; } }; hb_object_header_t header; @@ -136,7 +137,7 @@ struct hb_hashmap_t /* Insert back old items. */ if (old_items) for (unsigned int i = 0; i < old_size; i++) - if (old_items[i].key != kINVALID && old_items[i].value != vINVALID) + if (old_items[i].is_real ()) set (old_items[i].key, old_items[i].value); free (old_items); @@ -173,7 +174,7 @@ struct hb_hashmap_t { if (unlikely (!items)) return vINVALID; unsigned int i = bucket_for (key); - return !items[i].is_unused () && items[i] == key ? items[i].value : vINVALID; + return items[i].is_real () && items[i] == key ? items[i].value : vINVALID; } void del (K key) { set (key, vINVALID); }