summaryrefslogtreecommitdiff
path: root/fuzz/tagfuzzer.c
blob: 6f220ce2c83144007b532aee4856471a1a1f32d9 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* 
 * lt-tag.h
 * Copyright (C) 2011-2012 Akira TAGOH
 * 
 * Authors:
 *   Akira TAGOH  <akira@tagoh.org>
 * 
 * You may distribute under the terms of either the GNU
 * Lesser General Public License or the Mozilla Public
 * License, as specified in the README file.
 */

#include <stdint.h>
#include <stdlib.h>
#include <string.h>

#include <liblangtag/langtag.h>

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
	lt_tag_t *tag = 0;
	lt_error_t *error = 0;
	char *string = 0;

	string = malloc(size + 1);
	memcpy(string, data, size);
	string[size] = 0;

	lt_tag_parse(tag, string, &error);

	free(string);
	if (tag)
		lt_tag_unref(tag);
	if (error)
		lt_error_unref(error);

	return 0;
}