From 975bdd5ef562e37655067b703b2b9ca7481f4985 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 1 Jun 2018 17:37:13 -0700 Subject: [PATCH] [vector] Keep success status --- src/hb-private.hh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/hb-private.hh b/src/hb-private.hh index e626a1418..6fee049d1 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -625,11 +625,12 @@ struct CrapOrNull { #define HB_PREALLOCED_ARRAY_INIT {0, 0, nullptr} -template +template struct hb_vector_t { unsigned int len; unsigned int allocated; + bool successful; Type *arrayZ; Type static_array[StaticSize]; @@ -637,6 +638,7 @@ struct hb_vector_t { len = 0; allocated = ARRAY_LENGTH (static_array); + successful = true; arrayZ = static_array; } @@ -672,6 +674,9 @@ struct hb_vector_t /* Allocate for size but don't adjust len. */ inline bool alloc (unsigned int size) { + if (unlikely (!successful)) + return false; + if (likely (size <= allocated)) return true; @@ -697,7 +702,10 @@ struct hb_vector_t } if (unlikely (!new_array)) + { + successful = false; return false; + } arrayZ = new_array; allocated = new_allocated;