summaryrefslogtreecommitdiff
path: root/fuzz/tagfuzzer.cpp
blob: 2dcc9bb572b82f34700b0b366b2f951babcd8c92 (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
/* -*- 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 <cstdint>
#include <cstdlib>
#include <string>

#include <liblangtag/langtag.h>

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
	const std::string s(reinterpret_cast<const char *>(data), size);

	lt_tag_t *tag = 0;
	lt_error_t *error = 0;

	lt_tag_parse(tag, s.c_str(), &error);

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

	return 0;
}