Mozilla bug 580233 - check for zero-length record in hb sanitizer.
authorBehdad Esfahbod <behdad@behdad.org>
Wed, 21 Jul 2010 20:37:01 +0000 (16:37 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Wed, 21 Jul 2010 20:37:01 +0000 (16:37 -0400)
Patch / report by Jonathan Kew.

src/hb-open-type-private.hh

index 34d6cb0..cde6414 100644 (file)
@@ -229,7 +229,7 @@ struct hb_sanitize_context_t
   inline bool check_array (const void *base, unsigned int record_size, unsigned int len) const
   {
     const char *p = (const char *) base;
-    bool overflows = len >= ((unsigned int) -1) / record_size;
+    bool overflows = record_size > 0 && len >= ((unsigned int) -1) / record_size;
 
     if (HB_DEBUG_SANITIZE && (int) this->debug_depth < (int) HB_DEBUG_SANITIZE)
       fprintf (stderr, "SANITIZE(%p) %-*d-> array [%p..%p] (%d*%d=%ld bytes) in [%p..%p] -> %s\n", \