Coverage Report

Created: 2023-06-07 07:05

/src/fribidi/bin/fribidi-fuzzer.c
Line
Count
Source (jump to first uncovered line)
1
/* FriBidi
2
 * fribidi-fuzzer.c - fuzzer runner for libfribidi
3
 *
4
 * Copyright (C) 2020 Ebrahim Byagowi
5
 *
6
 * This library is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 2.1 of the License, or (at your option) any later version.
10
 *
11
 * This library is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public License
17
 * along with this library, in a file named COPYING; if not, write to the
18
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
 * Boston, MA 02110-1301, USA
20
 *
21
 * For licensing issues, contact <fribidi.license@gmail.com>.
22
 */
23
24
#include <stdint.h>
25
#include <stddef.h>
26
#include <stdlib.h>
27
#include <string.h>
28
#include <assert.h>
29
30
#include <fribidi.h>
31
32
int LLVMFuzzerTestOneInput (const uint8_t *data, size_t size)
33
1.88k
{
34
1.88k
  const FriBidiStrIndex str_len = size / 4;
35
1.88k
  FriBidiChar *str = (FriBidiChar *) data;
36
37
1.88k
  FriBidiCharType *types = calloc (str_len, sizeof (FriBidiCharType));
38
1.88k
  FriBidiBracketType *btypes = calloc (str_len, sizeof (FriBidiBracketType));
39
1.88k
  FriBidiLevel *levels = calloc (str_len, sizeof (FriBidiLevel));
40
1.88k
  fribidi_get_bidi_types (str, str_len, types);
41
1.88k
  fribidi_get_bracket_types (str, str_len, types, btypes);
42
1.88k
  FriBidiParType par_type = FRIBIDI_PAR_ON;
43
1.88k
  FriBidiLevel level = fribidi_get_par_embedding_levels_ex (types, btypes, str_len, &par_type, levels);
44
1.88k
  if ((0)) assert (level);
45
1.88k
  free (types);
46
1.88k
  free (btypes);
47
1.88k
  free (levels);
48
1.88k
  return 0;
49
1.88k
}
50
51
/* Editor directions:
52
 * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
53
 */