From: Behdad Esfahbod Date: Thu, 3 Jan 2013 05:02:59 +0000 (-0600) Subject: Protect sets in-error from further modication X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7b1b720a8da69b68b775ce17104a40d55401b7ef;p=platform%2Fupstream%2FlibHarfBuzzSharp.git Protect sets in-error from further modication Fixes test-set.c --- diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh index 8e03d68..5e30a7e 100644 --- a/src/hb-set-private.hh +++ b/src/hb-set-private.hh @@ -146,6 +146,9 @@ struct hb_set_t inline void fini (void) { } inline void clear (void) { + if (unlikely (hb_object_is_inert (this))) + return; + in_error = false; memset (elts, 0, sizeof elts); } inline bool is_empty (void) const { @@ -156,23 +159,27 @@ struct hb_set_t } inline void add (hb_codepoint_t g) { + if (unlikely (in_error)) return; if (unlikely (g == SENTINEL)) return; if (unlikely (g > MAX_G)) return; elt (g) |= mask (g); } inline void add_range (hb_codepoint_t a, hb_codepoint_t b) { + if (unlikely (in_error)) return; /* TODO Speedup */ for (unsigned int i = a; i < b + 1; i++) add (i); } inline void del (hb_codepoint_t g) { + if (unlikely (in_error)) return; if (unlikely (g > MAX_G)) return; elt (g) &= ~mask (g); } inline void del_range (hb_codepoint_t a, hb_codepoint_t b) { + if (unlikely (in_error)) return; /* TODO Speedup */ for (unsigned int i = a; i < b + 1; i++) del (i); @@ -202,31 +209,37 @@ struct hb_set_t } inline void set (const hb_set_t *other) { + if (unlikely (in_error)) return; for (unsigned int i = 0; i < ELTS; i++) elts[i] = other->elts[i]; } inline void union_ (const hb_set_t *other) { + if (unlikely (in_error)) return; for (unsigned int i = 0; i < ELTS; i++) elts[i] |= other->elts[i]; } inline void intersect (const hb_set_t *other) { + if (unlikely (in_error)) return; for (unsigned int i = 0; i < ELTS; i++) elts[i] &= other->elts[i]; } inline void subtract (const hb_set_t *other) { + if (unlikely (in_error)) return; for (unsigned int i = 0; i < ELTS; i++) elts[i] &= ~other->elts[i]; } inline void symmetric_difference (const hb_set_t *other) { + if (unlikely (in_error)) return; for (unsigned int i = 0; i < ELTS; i++) elts[i] ^= other->elts[i]; } inline void invert (void) { + if (unlikely (in_error)) return; for (unsigned int i = 0; i < ELTS; i++) elts[i] = ~elts[i]; }