Force blob generation and memory check in hb-subset-fuzzer
authorEbrahim Byagowi <ebrahim@gnu.org>
Wed, 10 Jul 2019 09:58:06 +0000 (14:28 +0430)
committerEbrahim Byagowi <ebrahim@gnu.org>
Wed, 10 Jul 2019 19:08:07 +0000 (23:38 +0430)
test/fuzzing/hb-subset-fuzzer.cc

index 73c95b2..38e7ec6 100644 (file)
@@ -3,6 +3,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <assert.h>
 
 #include "hb-subset.h"
 
@@ -32,6 +33,19 @@ trySubset (hb_face_t *face,
   }
 
   hb_face_t *result = hb_subset (face, input);
+  {
+    hb_blob_t *blob = hb_face_reference_blob (result);
+    unsigned int length;
+    const char *data = hb_blob_get_data (blob, &length);
+
+    // Something not optimizable just to access all the blob data
+    unsigned int bytes_count = 0;
+    for (unsigned int i = 0; i < length; ++i)
+      if (data[i]) ++bytes_count;
+    assert (bytes_count);
+
+    hb_blob_destroy (blob);
+  }
   hb_face_destroy (result);
 
   hb_subset_input_destroy (input);