Fix possible but improbable overflow in hb_array_t
authorBehdad Esfahbod <behdad@behdad.org>
Thu, 28 Apr 2011 16:58:28 +0000 (12:58 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Thu, 28 Apr 2011 16:58:28 +0000 (12:58 -0400)
src/hb-private.hh

index ce09d18..ca37084 100644 (file)
@@ -297,7 +297,7 @@ struct hb_static_array_t {
        array = new_array;
       }
     } else {
-      bool overflows = new_allocated >= ((unsigned int) -1) / sizeof (Type);
+      bool overflows = (new_allocated < allocated) || (new_allocated >= ((unsigned int) -1) / sizeof (Type));
       if (unlikely (overflows))
         new_array = NULL;
       else