1 // Copyright 2017 The PDFium Authors 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 "core/fxcrt/compiler_specific.h" 6 #include "core/fxcrt/fx_string.h" 7 #include "testing/fuzzers/pdfium_fuzzer_util.h" 8 #include "testing/fuzzers/xfa_process_state.h" 9 #include "xfa/fxfa/formcalc/cxfa_fmparser.h" 10 LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)11extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 12 auto* state = static_cast<XFAProcessState*>(FPDF_GetFuzzerPerProcessState()); 13 // SAFETY: required from fuzzer. 14 WideString input = 15 WideString::FromUTF8(UNSAFE_BUFFERS(ByteStringView(data, size))); 16 CXFA_FMLexer lexer(input.AsStringView()); 17 CXFA_FMParser parser(state->GetHeap(), &lexer); 18 parser.Parse(); 19 state->ForceGCAndPump(); 20 return 0; 21 } 22