[vector] Keep success status
diff --git a/src/hb-private.hh b/src/hb-private.hh
index e626a14..6fee049 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -625,11 +625,12 @@
#define HB_PREALLOCED_ARRAY_INIT {0, 0, nullptr}
-template <typename Type, unsigned int StaticSize=16>
+template <typename Type, unsigned int StaticSize=8>
struct hb_vector_t
{
unsigned int len;
unsigned int allocated;
+ bool successful;
Type *arrayZ;
Type static_array[StaticSize];
@@ -637,6 +638,7 @@
{
len = 0;
allocated = ARRAY_LENGTH (static_array);
+ successful = true;
arrayZ = static_array;
}
@@ -672,6 +674,9 @@
/* 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 @@
}
if (unlikely (!new_array))
+ {
+ successful = false;
return false;
+ }
arrayZ = new_array;
allocated = new_allocated;