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