Fix buffer_diff for empty buffers
authorBehdad Esfahbod <behdad@behdad.org>
Tue, 5 Sep 2017 03:14:13 +0000 (20:14 -0700)
committerBehdad Esfahbod <behdad@behdad.org>
Tue, 5 Sep 2017 03:14:13 +0000 (20:14 -0700)
If buffers are empty, content type should be ignored.

This fixes last of the failing tests: fuzzed.tests.  Green again!

src/hb-buffer.cc
src/hb-buffer.h
util/options.hh

index 6b05d3a6a98ec59ada0ae9d68516bd6d58d25c90..171d1016e3f652982b3fb8159ea45c7e4ca5d278 100644 (file)
@@ -1893,7 +1893,7 @@ hb_buffer_diff (hb_buffer_t *buffer,
                hb_codepoint_t dottedcircle_glyph,
                unsigned int position_fuzz)
 {
-  if (buffer->content_type != reference->content_type)
+  if (buffer->content_type != reference->content_type && buffer->len && reference->len)
     return HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH;
 
   hb_buffer_diff_flags_t result = HB_BUFFER_DIFF_FLAG_EQUAL;
index ffbf66ee12f50c16fae67e7f2e917e6c530dde10..1d633f7dcdd0fb4cd6f42e1893194b7d17e61226 100644 (file)
@@ -481,12 +481,12 @@ typedef enum { /*< flags >*/
 
   /* Buffers with different content_type cannot be meaningfully compared
    * in any further detail. */
-  HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH    = 0X0001,
+  HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH    = 0x0001,
 
   /* For buffers with differing length, the per-glyph comparison is not
    * attempted, though we do still scan reference for dottedcircle / .notdef
    * glyphs. */
-  HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH          = 0X0002,
+  HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH          = 0x0002,
 
   /* We want to know if dottedcircle / .notdef glyphs are present in the
    * reference, as we may not care so much about other differences in this
index b24ab0c8e8aff3ecc9a78e657bbb14a685918ba6..9feee2dc07dc0dd7651c660ba50d102ad2cddecf 100644 (file)
@@ -414,7 +414,7 @@ struct shape_options_t : option_group_t
     }
 
     bool ret = true;
-    hb_buffer_diff_flags_t diff = hb_buffer_diff (buffer, reconstruction, (hb_codepoint_t) -1, 0);
+    hb_buffer_diff_flags_t diff = hb_buffer_diff (reconstruction, buffer, (hb_codepoint_t) -1, 0);
     if (diff)
     {
       if (error)