X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=test%2Ffuzzing%2Fhb-subset-fuzzer.cc;h=428765ea32055fff1ed898bc0b1688e1bc0ff2b5;hb=a280f8312cc9b27515efbab292b95b9d147a2b73;hp=56ffd227119206584e08b215fd1056574e957257;hpb=610626019cd10944b76622e30b2610910bf4b2b8;p=platform%2Fupstream%2Fharfbuzz.git diff --git a/test/fuzzing/hb-subset-fuzzer.cc b/test/fuzzing/hb-subset-fuzzer.cc index 56ffd22..428765e 100644 --- a/test/fuzzing/hb-subset-fuzzer.cc +++ b/test/fuzzing/hb-subset-fuzzer.cc @@ -3,6 +3,7 @@ #include #include #include +#include #include "hb-subset.h" @@ -16,16 +17,35 @@ trySubset (hb_face_t *face, { hb_subset_input_t *input = hb_subset_input_create_or_fail (); hb_subset_input_set_drop_hints (input, drop_hints); - hb_subset_input_set_drop_layout (input, drop_layout); hb_subset_input_set_retain_gids (input, retain_gids); hb_set_t *codepoints = hb_subset_input_unicode_set (input); + if (!drop_layout) + { + hb_set_del (hb_subset_input_drop_tables_set (input), HB_TAG ('G', 'S', 'U', 'B')); + hb_set_del (hb_subset_input_drop_tables_set (input), HB_TAG ('G', 'P', 'O', 'S')); + hb_set_del (hb_subset_input_drop_tables_set (input), HB_TAG ('G', 'D', 'E', 'F')); + } + for (int i = 0; i < text_length; i++) { hb_set_add (codepoints, text[i]); } 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 || !length); + + hb_blob_destroy (blob); + } hb_face_destroy (result); hb_subset_input_destroy (input); @@ -47,7 +67,7 @@ trySubset (hb_face_t *face, extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { hb_blob_t *blob = hb_blob_create ((const char *)data, size, - HB_MEMORY_MODE_READONLY, NULL, NULL); + HB_MEMORY_MODE_READONLY, nullptr, nullptr); hb_face_t *face = hb_face_create (blob, 0); /* Just test this API here quickly. */