summaryrefslogtreecommitdiff
path: root/glib/tests/fuzzing/util_fuzzer.cc
blob: 6b6b10c3bc6d2671d74164ded17bed3a8ca3f0b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <poppler.h>

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
    char *tmp_ch;
    char *buf;
    gsize length;
    guint8 *tmp_uint;

    buf = (char *)calloc(size + 1, sizeof(char));
    memcpy(buf, data, size);
    buf[size] = '\0';

    tmp_ch = poppler_named_dest_from_bytestring((const guint8 *)buf, size);
    tmp_uint = poppler_named_dest_to_bytestring(buf, &length);

    g_free(tmp_ch);
    g_free(tmp_uint);
    free(buf);
    return 0;
}