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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |