blob: f02f006ea038c9cac447db34d946c7d49768c6c0 [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"
Dan Sinclair95bec802017-01-19 10:27:58 -05009#include "xfa/fde/css/cfde_csssyntaxparser.h"
dsinclair756d3792016-06-14 07:34:20 -070010#include "xfa/fde/css/fde_css.h"
dsinclair756d3792016-06-14 07:34:20 -070011#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
Dan Sinclaircff56182017-01-25 11:37:16 -050018 // If we convert the input into an empty string bail out.
19 if (input.GetLength() == 0)
20 return 0;
21
tsepez7cda31a2016-12-07 12:10:20 -080022 CFDE_CSSSyntaxParser parser;
Dan Sinclaircff56182017-01-25 11:37:16 -050023 parser.Init(input.c_str(), input.GetLength());
dsinclair756d3792016-06-14 07:34:20 -070024
Dan Sinclair96f482c2017-01-11 16:31:27 -050025 FDE_CSSSyntaxStatus status;
26 do {
dsinclair756d3792016-06-14 07:34:20 -070027 status = parser.DoSyntaxParse();
Dan Sinclair96f482c2017-01-11 16:31:27 -050028 } while (status != FDE_CSSSyntaxStatus::Error &&
29 status != FDE_CSSSyntaxStatus::EOS);
dsinclair756d3792016-06-14 07:34:20 -070030 return 0;
31}