OLD | NEW |
1 // Copyright 2016 The PDFium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <memory> | 5 #include <memory> |
6 | 6 |
| 7 #include "core/fxcrt/cfx_retain_ptr.h" |
7 #include "xfa/fde/xml/cfx_saxreader.h" | 8 #include "xfa/fde/xml/cfx_saxreader.h" |
8 #include "xfa/fgas/crt/fgas_stream.h" | 9 #include "xfa/fgas/crt/fgas_stream.h" |
9 #include "xfa/fxfa/parser/cxfa_widetextread.h" | 10 #include "xfa/fxfa/parser/cxfa_widetextread.h" |
10 | 11 |
11 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | 12 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
12 CFX_WideString input = CFX_WideString::FromUTF8( | 13 CFX_WideString input = CFX_WideString::FromUTF8( |
13 CFX_ByteStringC(data, static_cast<FX_STRSIZE>(size))); | 14 CFX_ByteStringC(data, static_cast<FX_STRSIZE>(size))); |
14 std::unique_ptr<IFGAS_Stream, ReleaseDeleter<IFGAS_Stream>> stream( | 15 auto stream = pdfium::MakeRetain<CXFA_WideTextRead>(input); |
15 new CXFA_WideTextRead(input)); | |
16 if (!stream) | 16 if (!stream) |
17 return 0; | 17 return 0; |
18 | 18 |
19 CFX_RetainPtr<IFX_SeekableReadStream> fileRead = | 19 CFX_RetainPtr<IFX_SeekableReadStream> fileRead = |
20 stream->MakeSeekableReadStream(); | 20 stream->MakeSeekableReadStream(); |
21 if (!fileRead) | 21 if (!fileRead) |
22 return 0; | 22 return 0; |
23 | 23 |
24 CFX_SAXReader reader; | 24 CFX_SAXReader reader; |
25 if (reader.StartParse(fileRead, 0, -1, CFX_SaxParseMode_NotSkipSpace) < 0) | 25 if (reader.StartParse(fileRead, 0, -1, CFX_SaxParseMode_NotSkipSpace) < 0) |
26 return 0; | 26 return 0; |
27 | 27 |
28 while (1) { | 28 while (1) { |
29 int32_t ret = reader.ContinueParse(nullptr); | 29 int32_t ret = reader.ContinueParse(nullptr); |
30 if (ret < 0 || ret > 99) | 30 if (ret < 0 || ret > 99) |
31 break; | 31 break; |
32 } | 32 } |
33 | 33 |
34 return 0; | 34 return 0; |
35 } | 35 } |
OLD | NEW |