Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: testing/libfuzzer/pdf_xml_fuzzer.cc

Issue 1861183002: Make CFX_WideString::FromUTF8() take a CFX_ByteStringC argument. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, combine delcs with initialization. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « testing/libfuzzer/pdf_fm2js_fuzzer.cc ('k') | xfa/fxbarcode/BC_UtilCodingConvert.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <limits> 7 #include <limits>
8 #include <memory> 8 #include <memory>
9 9
10 #include "core/fxcrt/include/fx_basic.h" 10 #include "core/fxcrt/include/fx_basic.h"
(...skipping 30 matching lines...) Expand all
41 return nullptr; 41 return nullptr;
42 } 42 }
43 43
44 } // namespace 44 } // namespace
45 45
46 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 46 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
47 if (size > std::numeric_limits<FX_STRSIZE>::max()) 47 if (size > std::numeric_limits<FX_STRSIZE>::max())
48 return 0; 48 return 0;
49 49
50 CFX_WideString input = CFX_WideString::FromUTF8( 50 CFX_WideString input = CFX_WideString::FromUTF8(
51 reinterpret_cast<const char*>(data), static_cast<FX_STRSIZE>(size)); 51 CFX_ByteStringC(data, static_cast<FX_STRSIZE>(size)));
52 std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> stream( 52 std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> stream(
53 XFA_CreateWideTextRead(input)); 53 XFA_CreateWideTextRead(input));
54 if (!stream) 54 if (!stream)
55 return 0; 55 return 0;
56 56
57 std::unique_ptr<CFDE_XMLDoc> doc(new CFDE_XMLDoc); 57 std::unique_ptr<CFDE_XMLDoc> doc(new CFDE_XMLDoc);
58 std::unique_ptr<CFDE_XMLParser, ReleaseDeleter<CFDE_XMLParser>> parser( 58 std::unique_ptr<CFDE_XMLParser, ReleaseDeleter<CFDE_XMLParser>> parser(
59 new CXFA_XMLParser(doc->GetRoot(), stream.get())); 59 new CXFA_XMLParser(doc->GetRoot(), stream.get()));
60 60
61 if (!doc->LoadXML(parser.release())) 61 if (!doc->LoadXML(parser.release()))
62 return 0; 62 return 0;
63 63
64 int32_t load_result = doc->DoLoad(nullptr); 64 int32_t load_result = doc->DoLoad(nullptr);
65 if (load_result < 100) 65 if (load_result < 100)
66 return 0; 66 return 0;
67 67
68 (void)XFA_FDEExtension_GetDocumentNode(doc.get()); 68 (void)XFA_FDEExtension_GetDocumentNode(doc.get());
69 return 0; 69 return 0;
70 } 70 }
OLDNEW
« no previous file with comments | « testing/libfuzzer/pdf_fm2js_fuzzer.cc ('k') | xfa/fxbarcode/BC_UtilCodingConvert.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698