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