[fuzzing] Take whatever text we can

This commit is contained in:
Behdad Esfahbod 2018-11-07 19:11:43 -05:00
parent 517a1bac97
commit 0bf76154f1
1 changed files with 13 additions and 11 deletions

View File

@ -25,9 +25,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
hb_buffer_destroy (buffer);
}
uint32_t text32[16];
if (size > sizeof (text32)) {
memcpy(text32, data + size - sizeof (text32), sizeof (text32));
uint32_t text32[16] = {0};
unsigned int len = sizeof (text32);
if (size < len)
len = size;
memcpy(text32, data + size - len, len);
hb_buffer_t *buffer = hb_buffer_create ();
hb_buffer_add_utf32 (buffer, text32, sizeof (text32) / sizeof (text32[0]), 0, -1);
hb_buffer_guess_segment_properties (buffer);
@ -36,7 +39,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
/* Misc calls on face. */
test_face (face, text32[15]);
}
hb_font_destroy (font);
hb_face_destroy (face);