1 // Copyright 2017 The PDFium 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 <cstring>
6 #include <memory>
7
8 #include "public/cpp/fpdf_scopers.h"
9 #include "public/fpdf_edit.h"
10 #include "public/fpdfview.h"
11
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)12 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
13 if (size < 2)
14 return 0;
15
16 ScopedFPDFDocument doc(FPDF_CreateNewDocument());
17 ScopedFPDFPage page(FPDFPage_New(doc.get(), 0, 612, 792));
18 int font_type = data[0];
19 FPDF_BOOL cid = data[1];
20 data += 2;
21 size -= 2;
22 ScopedFPDFFont font(FPDFText_LoadFont(doc.get(), data, size, font_type, cid));
23 if (!font)
24 return 0;
25
26 FPDF_PAGEOBJECT text_object =
27 FPDFPageObj_CreateTextObj(doc.get(), font.get(), 12.0f);
28 FPDFPage_InsertObject(page.get(), text_object);
29 FPDFPage_GenerateContent(page.get());
30 return 0;
31 }
32