Coverage Report

Created: 2025-08-29 06:14

/src/tinysparql/fuzzing/fuzz.h
Line
Count
Source
1
/*
2
 * Copyright 2018 pdknsk
3
 *
4
 * SPDX-License-Identifier: LGPL-2.1-or-later
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
17
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18
 */
19
20
#include <gio/gio.h>
21
#include <glib.h>
22
#include <sqlite3.h>
23
#include "tinysparql.h"
24
25
int LLVMFuzzerTestOneInput (const unsigned char *data, size_t size);
26
27
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
28
static GLogWriterOutput
29
empty_logging_func (GLogLevelFlags log_level, const GLogField *fields,
30
                    gsize n_fields, gpointer user_data)
31
2
{
32
2
  return G_LOG_WRITER_HANDLED;
33
2
}
34
#endif
35
36
/* Disables logging for oss-fuzz. Must be used with each target. */
37
static void
38
fuzz_set_logging_func (void)
39
5.42k
{
40
5.42k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
41
5.42k
  static gboolean writer_set = FALSE;
42
43
5.42k
  if (!writer_set) {
44
1
    g_log_set_writer_func (empty_logging_func, NULL, NULL);
45
1
    writer_set = TRUE;
46
1
  }
47
5.42k
#endif
48
5.42k
}