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

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

Issue 2555373002: Use unique_ptr for CXFA_XMLParser. (Closed)
Patch Set: Alphabetize class Created 4 years 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 | « no previous file | xfa/fde/xml/fde_xml_imp.h » ('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 <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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 auto stream = pdfium::MakeRetain<CXFA_WideTextRead>(input); 55 auto stream = pdfium::MakeRetain<CXFA_WideTextRead>(input);
56 if (!stream) 56 if (!stream)
57 return 0; 57 return 0;
58 58
59 std::unique_ptr<CFDE_XMLDoc> doc = pdfium::MakeUnique<CFDE_XMLDoc>(); 59 auto doc = pdfium::MakeUnique<CFDE_XMLDoc>();
60 std::unique_ptr<CFDE_XMLParser, ReleaseDeleter<CFDE_XMLParser>> parser( 60 if (!doc->LoadXML(pdfium::MakeUnique<CXFA_XMLParser>(doc->GetRoot(), stream)))
61 new CXFA_XMLParser(doc->GetRoot(), stream));
62 if (!doc->LoadXML(parser.release()))
63 return 0; 61 return 0;
64 62
65 int32_t load_result = doc->DoLoad(nullptr); 63 if (doc->DoLoad(nullptr) < 100)
66 if (load_result < 100)
67 return 0; 64 return 0;
68 65
69 (void)XFA_FDEExtension_GetDocumentNode(doc.get()); 66 (void)XFA_FDEExtension_GetDocumentNode(doc.get());
70 return 0; 67 return 0;
71 } 68 }
OLDNEW
« no previous file with comments | « no previous file | xfa/fde/xml/fde_xml_imp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698