2016-12-21 03:52:50 +01:00
|
|
|
#include "hb-fuzzer.hh"
|
|
|
|
|
2015-11-06 08:08:50 +01:00
|
|
|
#include <hb-ot.h>
|
2016-01-11 19:31:04 +01:00
|
|
|
#include <string.h>
|
2015-10-12 23:39:52 +02:00
|
|
|
|
2018-11-04 08:47:34 +01:00
|
|
|
#define TEST_OT_FACE_NO_MAIN 1
|
|
|
|
#include "../api/test-ot-face.c"
|
|
|
|
#undef TEST_OT_FACE_NO_MAIN
|
|
|
|
|
2016-12-21 03:52:50 +01:00
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|
|
|
{
|
2018-10-19 07:36:42 +02:00
|
|
|
hb_blob_t *blob = hb_blob_create ((const char *)data, size,
|
2019-06-03 10:00:25 +02:00
|
|
|
HB_MEMORY_MODE_READONLY, nullptr, nullptr);
|
2018-10-19 07:36:42 +02:00
|
|
|
hb_face_t *face = hb_face_create (blob, 0);
|
|
|
|
hb_font_t *font = hb_font_create (face);
|
|
|
|
hb_ot_font_set_funcs (font);
|
|
|
|
hb_font_set_scale (font, 12, 12);
|
2015-10-12 23:39:52 +02:00
|
|
|
|
2016-01-11 19:31:04 +01:00
|
|
|
{
|
|
|
|
const char text[] = "ABCDEXYZ123@_%&)*$!";
|
2018-10-19 07:36:42 +02:00
|
|
|
hb_buffer_t *buffer = hb_buffer_create ();
|
|
|
|
hb_buffer_add_utf8 (buffer, text, -1, 0, -1);
|
|
|
|
hb_buffer_guess_segment_properties (buffer);
|
2019-06-03 10:00:25 +02:00
|
|
|
hb_shape (font, buffer, nullptr, 0);
|
2018-10-19 07:36:42 +02:00
|
|
|
hb_buffer_destroy (buffer);
|
2016-01-11 19:31:04 +01:00
|
|
|
}
|
|
|
|
|
2018-11-08 01:11:43 +01:00
|
|
|
uint32_t text32[16] = {0};
|
|
|
|
unsigned int len = sizeof (text32);
|
|
|
|
if (size < len)
|
|
|
|
len = size;
|
|
|
|
memcpy(text32, data + size - len, len);
|
2015-10-12 23:39:52 +02:00
|
|
|
|
2018-11-08 01:11:43 +01:00
|
|
|
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);
|
2019-06-03 10:00:25 +02:00
|
|
|
hb_shape (font, buffer, nullptr, 0);
|
2018-11-08 01:11:43 +01:00
|
|
|
hb_buffer_destroy (buffer);
|
|
|
|
|
|
|
|
/* Misc calls on face. */
|
|
|
|
test_face (face, text32[15]);
|
2015-10-12 23:39:52 +02:00
|
|
|
|
2018-10-19 07:36:42 +02:00
|
|
|
hb_font_destroy (font);
|
|
|
|
hb_face_destroy (face);
|
|
|
|
hb_blob_destroy (blob);
|
2015-10-12 23:39:52 +02:00
|
|
|
return 0;
|
|
|
|
}
|