Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: testing/libfuzzer/fuzzers/ft_new_memory_face_fuzzer.cc

Issue 1776323002: [libfuzzer] Add fuzzer for FT_New_Memory_Face() from third_party/freetype2. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the nit. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « testing/libfuzzer/fuzzers/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <stddef.h>
6 #include <stdint.h>
7
8 #include "third_party/freetype2/src/include/ft2build.h"
9 #include "third_party/freetype2/src/include/freetype/freetype.h"
10
11
12 FT_Error g_init_freetype_error;
13
14
15 struct InitFreetype {
16 FT_Library* library_;
17 InitFreetype(FT_Library* library) : library_(library) {
18 g_init_freetype_error = FT_Init_FreeType(library);
19 }
20 ~InitFreetype() {
21 FT_Init_FreeType(library_);
22 }
23 };
24
25
26 FT_Library g_freetype_library;
27 InitFreetype g_init_freetype(&g_freetype_library);
28
29
30 // Entry point for LibFuzzer.
31 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
32 if (g_init_freetype_error)
33 return 0;
34
35 FT_Face face;
36 // Get number of faces in font. Usually 0 for random data.
37 FT_Error error = FT_New_Memory_Face(g_freetype_library, data, size, -1,
38 &face);
39 if (error)
40 return 0;
41
42 // Go through the faces.
43 for (FT_Long face_index = 0; face_index < face->num_faces + 1; ++face_index) {
44 FT_Face temp_face;
45 error = FT_New_Memory_Face(g_freetype_library, data, size, face_index,
46 &temp_face);
47 if (error)
48 break;
49 FT_Done_Face(temp_face);
50 }
51
52 FT_Done_Face(face);
53
54 return 0;
55 }
OLDNEW
« no previous file with comments | « testing/libfuzzer/fuzzers/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698