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 <cstddef> | 5 #include <cstddef> |
6 #include <cstdint> | 6 #include <cstdint> |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "core/fxcrt/fx_basic.h" | 9 #include "core/fxcrt/fx_basic.h" |
10 #include "core/fxcrt/fx_safe_types.h" | 10 #include "core/fxcrt/fx_safe_types.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 } // namespace | 46 } // namespace |
47 | 47 |
48 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | 48 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
49 FX_SAFE_STRSIZE safe_size = size; | 49 FX_SAFE_STRSIZE safe_size = size; |
50 if (!safe_size.IsValid()) | 50 if (!safe_size.IsValid()) |
51 return 0; | 51 return 0; |
52 | 52 |
53 CFX_WideString input = | 53 CFX_WideString input = |
54 CFX_WideString::FromUTF8(CFX_ByteStringC(data, safe_size.ValueOrDie())); | 54 CFX_WideString::FromUTF8(CFX_ByteStringC(data, safe_size.ValueOrDie())); |
55 std::unique_ptr<IFGAS_Stream, ReleaseDeleter<IFGAS_Stream>> stream( | 55 auto stream = pdfium::MakeRetain<CXFA_WideTextRead>(input); |
56 new CXFA_WideTextRead(input)); | |
57 if (!stream) | 56 if (!stream) |
58 return 0; | 57 return 0; |
59 | 58 |
60 std::unique_ptr<CFDE_XMLDoc> doc = pdfium::MakeUnique<CFDE_XMLDoc>(); | 59 std::unique_ptr<CFDE_XMLDoc> doc = pdfium::MakeUnique<CFDE_XMLDoc>(); |
61 std::unique_ptr<CFDE_XMLParser, ReleaseDeleter<CFDE_XMLParser>> parser( | 60 std::unique_ptr<CFDE_XMLParser, ReleaseDeleter<CFDE_XMLParser>> parser( |
62 new CXFA_XMLParser(doc->GetRoot(), stream.get())); | 61 new CXFA_XMLParser(doc->GetRoot(), stream)); |
63 | |
64 if (!doc->LoadXML(parser.release())) | 62 if (!doc->LoadXML(parser.release())) |
65 return 0; | 63 return 0; |
66 | 64 |
67 int32_t load_result = doc->DoLoad(nullptr); | 65 int32_t load_result = doc->DoLoad(nullptr); |
68 if (load_result < 100) | 66 if (load_result < 100) |
69 return 0; | 67 return 0; |
70 | 68 |
71 (void)XFA_FDEExtension_GetDocumentNode(doc.get()); | 69 (void)XFA_FDEExtension_GetDocumentNode(doc.get()); |
72 return 0; | 70 return 0; |
73 } | 71 } |
OLD | NEW |