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

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

Issue 2498223005: Make CPDF_Array take unique_ptrs (Closed)
Patch Set: nits Created 4 years, 1 month 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 | « fpdfsdk/fpdfsave.cpp ('k') | no next file » | 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 <cstdint> 5 #include <cstdint>
6 6
7 #include "core/fpdfapi/parser/cpdf_array.h" 7 #include "core/fpdfapi/parser/cpdf_array.h"
8 #include "core/fpdfapi/parser/cpdf_dictionary.h" 8 #include "core/fpdfapi/parser/cpdf_dictionary.h"
9 #include "core/fpdfapi/parser/cpdf_hint_tables.h" 9 #include "core/fpdfapi/parser/cpdf_hint_tables.h"
10 #include "core/fpdfapi/parser/cpdf_linearized_header.h" 10 #include "core/fpdfapi/parser/cpdf_linearized_header.h"
11 #include "core/fpdfapi/parser/cpdf_number.h"
11 #include "third_party/base/ptr_util.h" 12 #include "third_party/base/ptr_util.h"
12 13
13 int32_t GetData(const int32_t** data32, const uint8_t** data, size_t* size) { 14 int32_t GetData(const int32_t** data32, const uint8_t** data, size_t* size) {
14 const int32_t* ret = *data32; 15 const int32_t* ret = *data32;
15 ++(*data32); 16 ++(*data32);
16 *data += 4; 17 *data += 4;
17 *size -= 4; 18 *size -= 4;
18 return *ret; 19 return *ret;
19 } 20 }
20 21
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 linearized_dict->SetIntegerFor("E", GetData(&data32, &data, &size)); 67 linearized_dict->SetIntegerFor("E", GetData(&data32, &data, &size));
67 // Set page count 68 // Set page count
68 linearized_dict->SetIntegerFor("N", GetData(&data32, &data, &size)); 69 linearized_dict->SetIntegerFor("N", GetData(&data32, &data, &size));
69 // Set first page obj num 70 // Set first page obj num
70 linearized_dict->SetIntegerFor("O", GetData(&data32, &data, &size)); 71 linearized_dict->SetIntegerFor("O", GetData(&data32, &data, &size));
71 // Set first page no 72 // Set first page no
72 linearized_dict->SetIntegerFor("P", GetData(&data32, &data, &size)); 73 linearized_dict->SetIntegerFor("P", GetData(&data32, &data, &size));
73 74
74 auto hint_info = pdfium::MakeUnique<CPDF_Array>(); 75 auto hint_info = pdfium::MakeUnique<CPDF_Array>();
75 // Add primary hint stream offset 76 // Add primary hint stream offset
76 hint_info->AddInteger(GetData(&data32, &data, &size)); 77 hint_info->AddNew<CPDF_Number>(GetData(&data32, &data, &size));
77 // Add primary hint stream size 78 // Add primary hint stream size
78 hint_info->AddInteger(GetData(&data32, &data, &size)); 79 hint_info->AddNew<CPDF_Number>(GetData(&data32, &data, &size));
79 // Set hint stream info. 80 // Set hint stream info.
80 linearized_dict->SetFor("H", hint_info.release()); 81 linearized_dict->SetFor("H", hint_info.release());
81 82
82 const int shared_hint_table_offset = GetData(&data32, &data, &size); 83 const int shared_hint_table_offset = GetData(&data32, &data, &size);
83 84
84 { 85 {
85 FakeLinearized linearized(linearized_dict.get()); 86 FakeLinearized linearized(linearized_dict.get());
86 HintTableForFuzzing hint_table(&linearized, shared_hint_table_offset); 87 HintTableForFuzzing hint_table(&linearized, shared_hint_table_offset);
87 hint_table.Fuzz(data, size); 88 hint_table.Fuzz(data, size);
88 } 89 }
89 return 0; 90 return 0;
90 } 91 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfsave.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698