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_deleters.h" 9 #include "public/fpdf_edit.h" 10 #include "public/fpdfview.h" 11 12 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 13 if (size < 2) 14 return 0; 15 16 std::unique_ptr<void, FPDFDocumentDeleter> doc(FPDF_CreateNewDocument()); 17 std::unique_ptr<void, FPDFPageDeleter> page( 18 FPDFPage_New(doc.get(), 0, 612, 792)); 19 int font_type = data[0]; 20 FPDF_BOOL cid = data[1]; 21 data += 2; 22 size -= 2; 23 std::unique_ptr<void, FPDFFontDeleter> font( 24 FPDFText_LoadFont(doc.get(), data, size, font_type, cid)); 25 if (!font) 26 return 0; 27 28 FPDF_PAGEOBJECT text_object = 29 FPDFPageObj_CreateTextObj(doc.get(), font.get(), 12.0f); 30 FPDFPage_InsertObject(page.get(), text_object); 31 FPDFPage_GenerateContent(page.get()); 32 return 0; 33 } 34