• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 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/css/cfx_css.h"
6 #include "core/fxcrt/css/cfx_csssyntaxparser.h"
7 #include "core/fxcrt/fx_string.h"
8 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)9 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
10   // SAFETY: required from fuzzer.
11   WideString input = WideString::FromUTF8(
12       UNSAFE_BUFFERS(ByteStringView(data, static_cast<size_t>(size))));
13 
14   // If we convert the input into an empty string bail out.
15   if (input.IsEmpty())
16     return 0;
17 
18   CFX_CSSSyntaxParser parser(input.AsStringView());
19   CFX_CSSSyntaxParser::Status status;
20   do {
21     status = parser.DoSyntaxParse();
22   } while (status != CFX_CSSSyntaxParser::Status::kError &&
23            status != CFX_CSSSyntaxParser::Status::kEOS);
24   return 0;
25 }
26