blob: 247c9b92453b38790182ef6d80b76839a5f4ffe1 [file] [log] [blame]
dsinclair756d3792016-06-14 07:34:20 -07001// 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
tsepez7cda31a2016-12-07 12:10:20 -08007#include "core/fxcrt/cfx_retain_ptr.h"
npm43c8a6a2016-09-30 08:37:51 -07008#include "core/fxcrt/fx_string.h"
dsinclair756d3792016-06-14 07:34:20 -07009#include "xfa/fde/css/fde_css.h"
10#include "xfa/fde/css/fde_csssyntax.h"
11#include "xfa/fgas/crt/fgas_stream.h"
dsinclair9eb0db12016-07-21 12:01:39 -070012#include "xfa/fxfa/parser/cxfa_widetextread.h"
dsinclair756d3792016-06-14 07:34:20 -070013
14extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
dsinclair756d3792016-06-14 07:34:20 -070015 CFX_WideString input = CFX_WideString::FromUTF8(
16 CFX_ByteStringC(data, static_cast<FX_STRSIZE>(size)));
tsepez7cda31a2016-12-07 12:10:20 -080017
18 auto stream = pdfium::MakeRetain<CXFA_WideTextRead>(input);
dsinclair756d3792016-06-14 07:34:20 -070019 if (!stream)
20 return 0;
21
tsepez7cda31a2016-12-07 12:10:20 -080022 CFDE_CSSSyntaxParser parser;
23 parser.Init(stream, 1024);
dsinclair756d3792016-06-14 07:34:20 -070024
25 FDE_CSSSYNTAXSTATUS status = parser.DoSyntaxParse();
26 while (status != FDE_CSSSYNTAXSTATUS_Error &&
27 status != FDE_CSSSYNTAXSTATUS_EOS)
28 status = parser.DoSyntaxParse();
29
30 return 0;
31}