mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-13 08:42:59 +00:00
[test-draw] Make ubsan happy
This commit is contained in:
parent
b106a9ef58
commit
b43901151f
1 changed files with 19 additions and 15 deletions
|
@ -96,11 +96,12 @@ test_itoa (void)
|
|||
}
|
||||
|
||||
static void
|
||||
move_to (HB_UNUSED hb_draw_funcs_t *dfuncs, draw_data_t *draw_data,
|
||||
move_to (HB_UNUSED hb_draw_funcs_t *dfuncs, void *draw_data_,
|
||||
HB_UNUSED hb_draw_state_t *st,
|
||||
float to_x, float to_y,
|
||||
HB_UNUSED void *user_data)
|
||||
{
|
||||
draw_data_t *draw_data = (draw_data_t *) draw_data_;
|
||||
/* 4 = command character space + comma + array starts with 0 index + nul character space */
|
||||
if (draw_data->consumed + 2 * ITOA_BUF_SIZE + 4 > draw_data->size) return;
|
||||
draw_data->str[draw_data->consumed++] = 'M';
|
||||
|
@ -110,11 +111,12 @@ move_to (HB_UNUSED hb_draw_funcs_t *dfuncs, draw_data_t *draw_data,
|
|||
}
|
||||
|
||||
static void
|
||||
line_to (HB_UNUSED hb_draw_funcs_t *dfuncs, draw_data_t *draw_data,
|
||||
line_to (HB_UNUSED hb_draw_funcs_t *dfuncs, void *draw_data_,
|
||||
HB_UNUSED hb_draw_state_t *st,
|
||||
float to_x, float to_y,
|
||||
HB_UNUSED void *user_data)
|
||||
{
|
||||
draw_data_t *draw_data = (draw_data_t *) draw_data_;
|
||||
if (draw_data->consumed + 2 * ITOA_BUF_SIZE + 4 > draw_data->size) return;
|
||||
draw_data->str[draw_data->consumed++] = 'L';
|
||||
draw_data->consumed += _hb_itoa (to_x, draw_data->str + draw_data->consumed);
|
||||
|
@ -123,13 +125,13 @@ line_to (HB_UNUSED hb_draw_funcs_t *dfuncs, draw_data_t *draw_data,
|
|||
}
|
||||
|
||||
static void
|
||||
quadratic_to (HB_UNUSED hb_draw_funcs_t *dfuncs, draw_data_t *draw_data,
|
||||
quadratic_to (HB_UNUSED hb_draw_funcs_t *dfuncs, void *draw_data_,
|
||||
HB_UNUSED hb_draw_state_t *st,
|
||||
float control_x, float control_y,
|
||||
float to_x, float to_y,
|
||||
HB_UNUSED void *user_data)
|
||||
{
|
||||
|
||||
draw_data_t *draw_data = (draw_data_t *) draw_data_;
|
||||
if (draw_data->consumed + 4 * ITOA_BUF_SIZE + 6 > draw_data->size) return;
|
||||
draw_data->str[draw_data->consumed++] = 'Q';
|
||||
draw_data->consumed += _hb_itoa (control_x, draw_data->str + draw_data->consumed);
|
||||
|
@ -142,13 +144,14 @@ quadratic_to (HB_UNUSED hb_draw_funcs_t *dfuncs, draw_data_t *draw_data,
|
|||
}
|
||||
|
||||
static void
|
||||
cubic_to (HB_UNUSED hb_draw_funcs_t *dfuncs, draw_data_t *draw_data,
|
||||
cubic_to (HB_UNUSED hb_draw_funcs_t *dfuncs, void *draw_data_,
|
||||
HB_UNUSED hb_draw_state_t *st,
|
||||
float control1_x, float control1_y,
|
||||
float control2_x, float control2_y,
|
||||
float to_x, float to_y,
|
||||
HB_UNUSED void *user_data)
|
||||
{
|
||||
draw_data_t *draw_data = (draw_data_t *) draw_data_;
|
||||
if (draw_data->consumed + 6 * ITOA_BUF_SIZE + 8 > draw_data->size) return;
|
||||
draw_data->str[draw_data->consumed++] = 'C';
|
||||
draw_data->consumed += _hb_itoa (control1_x, draw_data->str + draw_data->consumed);
|
||||
|
@ -165,10 +168,11 @@ cubic_to (HB_UNUSED hb_draw_funcs_t *dfuncs, draw_data_t *draw_data,
|
|||
}
|
||||
|
||||
static void
|
||||
close_path (HB_UNUSED hb_draw_funcs_t *dfuncs, draw_data_t *draw_data,
|
||||
close_path (HB_UNUSED hb_draw_funcs_t *dfuncs, void *draw_data_,
|
||||
HB_UNUSED hb_draw_state_t *st,
|
||||
HB_UNUSED void *user_data)
|
||||
{
|
||||
draw_data_t *draw_data = (draw_data_t *) draw_data_;
|
||||
if (draw_data->consumed + 2 > draw_data->size) return;
|
||||
draw_data->str[draw_data->consumed++] = 'Z';
|
||||
}
|
||||
|
@ -1156,18 +1160,18 @@ int
|
|||
main (int argc, char **argv)
|
||||
{
|
||||
funcs = hb_draw_funcs_create ();
|
||||
hb_draw_funcs_set_move_to_func (funcs, (hb_draw_move_to_func_t) move_to, NULL, NULL);
|
||||
hb_draw_funcs_set_line_to_func (funcs, (hb_draw_line_to_func_t) line_to, NULL, NULL);
|
||||
hb_draw_funcs_set_quadratic_to_func (funcs, (hb_draw_quadratic_to_func_t) quadratic_to, NULL, NULL);
|
||||
hb_draw_funcs_set_cubic_to_func (funcs, (hb_draw_cubic_to_func_t) cubic_to, NULL, NULL);
|
||||
hb_draw_funcs_set_close_path_func (funcs, (hb_draw_close_path_func_t) close_path, NULL, NULL);
|
||||
hb_draw_funcs_set_move_to_func (funcs, move_to, NULL, NULL);
|
||||
hb_draw_funcs_set_line_to_func (funcs, line_to, NULL, NULL);
|
||||
hb_draw_funcs_set_quadratic_to_func (funcs, quadratic_to, NULL, NULL);
|
||||
hb_draw_funcs_set_cubic_to_func (funcs, cubic_to, NULL, NULL);
|
||||
hb_draw_funcs_set_close_path_func (funcs, close_path, NULL, NULL);
|
||||
hb_draw_funcs_make_immutable (funcs);
|
||||
|
||||
funcs2 = hb_draw_funcs_create ();
|
||||
hb_draw_funcs_set_move_to_func (funcs2, (hb_draw_move_to_func_t) move_to, NULL, NULL);
|
||||
hb_draw_funcs_set_line_to_func (funcs2, (hb_draw_line_to_func_t) line_to, NULL, NULL);
|
||||
hb_draw_funcs_set_cubic_to_func (funcs2, (hb_draw_cubic_to_func_t) cubic_to, NULL, NULL);
|
||||
hb_draw_funcs_set_close_path_func (funcs2, (hb_draw_close_path_func_t) close_path, NULL, NULL);
|
||||
hb_draw_funcs_set_move_to_func (funcs2, move_to, NULL, NULL);
|
||||
hb_draw_funcs_set_line_to_func (funcs2, line_to, NULL, NULL);
|
||||
hb_draw_funcs_set_cubic_to_func (funcs2, cubic_to, NULL, NULL);
|
||||
hb_draw_funcs_set_close_path_func (funcs2, close_path, NULL, NULL);
|
||||
hb_draw_funcs_make_immutable (funcs2);
|
||||
|
||||
hb_test_init (&argc, &argv);
|
||||
|
|
Loading…
Add table
Reference in a new issue