1 // Copyright 2016 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 <memory> 6 7 #include "core/fxcrt/cfx_retain_ptr.h" 8 #include "core/fxcrt/fx_string.h" 9 #include "xfa/fde/css/cfde_csssyntaxparser.h" 10 #include "xfa/fde/css/fde_css.h" 11 #include "xfa/fgas/crt/fgas_stream.h" 12 #include "xfa/fxfa/parser/cxfa_widetextread.h" 13 LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)14extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 15 CFX_WideString input = CFX_WideString::FromUTF8( 16 CFX_ByteStringC(data, static_cast<FX_STRSIZE>(size))); 17 18 // If we convert the input into an empty string bail out. 19 if (input.GetLength() == 0) 20 return 0; 21 22 CFDE_CSSSyntaxParser parser; 23 parser.Init(input.c_str(), input.GetLength()); 24 25 FDE_CSSSyntaxStatus status; 26 do { 27 status = parser.DoSyntaxParse(); 28 } while (status != FDE_CSSSyntaxStatus::Error && 29 status != FDE_CSSSyntaxStatus::EOS); 30 return 0; 31 } 32