diff options
author | tsepez <tsepez@chromium.org> | 2016-09-30 10:45:06 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-30 10:45:06 -0700 |
commit | cd5bca472261cebc60b37d7bbc8b81b4091a6cd6 (patch) | |
tree | be1e582a4a834c3f1f2ee2e4f9724ee488935b0c | |
parent | 43c8a6adc0045c974fb1c831deeef53fa5a38a82 (diff) | |
download | pdfium-chromium/2877.tar.xz |
Fix build of pdf_hint_table_fuzzer.chromium/2877
Restore CPDF_Dictionary default constructor.
Use it in places where reasonable in the code.
TBR=dsinclair@chromium.org
TBR=thestig@chromium.org
Review-Url: https://codereview.chromium.org/2383843002
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp | 3 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_dictionary.h | 1 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp | 22 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_parser/cpdf_stream.cpp | 2 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_filespec_unittest.cpp | 4 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_formfield_unittest.cpp | 12 | ||||
-rw-r--r-- | core/fxge/dib/fx_dib_engine_unittest.cpp | 2 | ||||
-rw-r--r-- | fpdfsdk/fpdfdoc_unittest.cpp | 8 |
8 files changed, 24 insertions, 30 deletions
diff --git a/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp b/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp index 5b9699d019..5696fc0c8d 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp @@ -19,6 +19,9 @@ #include "third_party/base/logging.h" #include "third_party/base/stl_util.h" +CPDF_Dictionary::CPDF_Dictionary() + : CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>()) {} + CPDF_Dictionary::CPDF_Dictionary(const CFX_WeakPtr<CFX_ByteStringPool>& pPool) : m_pPool(pPool) {} diff --git a/core/fpdfapi/fpdf_parser/cpdf_dictionary.h b/core/fpdfapi/fpdf_parser/cpdf_dictionary.h index 07903f5bd7..e3fd594575 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_dictionary.h +++ b/core/fpdfapi/fpdf_parser/cpdf_dictionary.h @@ -23,6 +23,7 @@ class CPDF_Dictionary : public CPDF_Object { using iterator = std::map<CFX_ByteString, CPDF_Object*>::iterator; using const_iterator = std::map<CFX_ByteString, CPDF_Object*>::const_iterator; + CPDF_Dictionary(); explicit CPDF_Dictionary(const CFX_WeakPtr<CFX_ByteStringPool>& pPool); // CPDF_Object. diff --git a/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp b/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp index beeb8f30c9..9b702099bb 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp @@ -66,7 +66,7 @@ class PDFObjectsTest : public testing::Test { m_ArrayObj->InsertAt(0, new CPDF_Number(8902)); m_ArrayObj->InsertAt(1, new CPDF_Name("address")); // Dictionary object. - m_DictObj = new CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>()); + m_DictObj = new CPDF_Dictionary(); m_DictObj->SetFor("bool", new CPDF_Boolean(false)); m_DictObj->SetFor("num", new CPDF_Number(0.23f)); // Stream object. @@ -74,7 +74,7 @@ class PDFObjectsTest : public testing::Test { size_t buf_len = FX_ArraySize(content); uint8_t* buf = reinterpret_cast<uint8_t*>(malloc(buf_len)); memcpy(buf, content, buf_len); - m_StreamDictObj = new CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>()); + m_StreamDictObj = new CPDF_Dictionary(); m_StreamDictObj->SetFor("key1", new CPDF_String(L" test dict")); m_StreamDictObj->SetFor("key2", new CPDF_Number(-1)); CPDF_Stream* stream_obj = new CPDF_Stream(buf, buf_len, m_StreamDictObj); @@ -553,7 +553,7 @@ TEST(PDFArrayTest, GetTypeAt) { CPDF_Dictionary* vals[3]; ScopedArray arr(new CPDF_Array); for (size_t i = 0; i < 3; ++i) { - vals[i] = new CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>()); + vals[i] = new CPDF_Dictionary(); for (size_t j = 0; j < 3; ++j) { std::string key("key"); char buf[33]; @@ -580,7 +580,7 @@ TEST(PDFArrayTest, GetTypeAt) { CPDF_Stream* stream_vals[3]; ScopedArray arr(new CPDF_Array); for (size_t i = 0; i < 3; ++i) { - vals[i] = new CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>()); + vals[i] = new CPDF_Dictionary(); for (size_t j = 0; j < 3; ++j) { std::string key("key"); char buf[33]; @@ -625,13 +625,11 @@ TEST(PDFArrayTest, GetTypeAt) { arr_val->AddNumber(1); arr_val->AddNumber(2); arr->InsertAt(11, arr_val); - CPDF_Dictionary* dict_val = - new CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>()); + CPDF_Dictionary* dict_val = new CPDF_Dictionary(); dict_val->SetFor("key1", new CPDF_String("Linda", false)); dict_val->SetFor("key2", new CPDF_String("Zoe", false)); arr->InsertAt(12, dict_val); - CPDF_Dictionary* stream_dict = - new CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>()); + CPDF_Dictionary* stream_dict = new CPDF_Dictionary(); stream_dict->SetFor("key1", new CPDF_String("John", false)); stream_dict->SetFor("key2", new CPDF_String("King", false)); uint8_t data[] = "A stream for test"; @@ -770,7 +768,7 @@ TEST(PDFArrayTest, CloneDirectObject) { TEST(PDFDictionaryTest, CloneDirectObject) { CPDF_IndirectObjectHolder objects_holder; - ScopedDict dict(new CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>())); + ScopedDict dict(new CPDF_Dictionary()); dict->SetReferenceFor("foo", &objects_holder, 1234); ASSERT_EQ(1U, dict->GetCount()); CPDF_Object* obj = dict->GetObjectFor("foo"); @@ -792,8 +790,7 @@ TEST(PDFObjectTest, CloneCheckLoop) { // Create an object with a reference loop. ScopedArray arr_obj(new CPDF_Array); // Dictionary object. - CPDF_Dictionary* dict_obj = - new CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>()); + CPDF_Dictionary* dict_obj = new CPDF_Dictionary(); dict_obj->SetFor("arr", arr_obj.get()); arr_obj->InsertAt(0, dict_obj); @@ -811,8 +808,7 @@ TEST(PDFObjectTest, CloneCheckLoop) { { CPDF_IndirectObjectHolder objects_holder; // Create an object with a reference loop. - CPDF_Dictionary* dict_obj = - new CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>()); + CPDF_Dictionary* dict_obj = new CPDF_Dictionary(); CPDF_Array* arr_obj = new CPDF_Array; objects_holder.AddIndirectObject(dict_obj); EXPECT_EQ(1u, dict_obj->GetObjNum()); diff --git a/core/fpdfapi/fpdf_parser/cpdf_stream.cpp b/core/fpdfapi/fpdf_parser/cpdf_stream.cpp index 88d04203a1..4f6d046397 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_stream.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_stream.cpp @@ -93,7 +93,7 @@ void CPDF_Stream::SetData(const uint8_t* pData, uint32_t size) { FXSYS_memcpy(m_pDataBuf.get(), pData, size); m_dwSize = size; if (!m_pDict) - m_pDict.reset(new CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>())); + m_pDict.reset(new CPDF_Dictionary()); m_pDict->SetIntegerFor("Length", size); m_pDict->RemoveFor("Filter"); m_pDict->RemoveFor("DecodeParms"); diff --git a/core/fpdfdoc/cpdf_filespec_unittest.cpp b/core/fpdfdoc/cpdf_filespec_unittest.cpp index c0f08dc480..3daba53aba 100644 --- a/core/fpdfdoc/cpdf_filespec_unittest.cpp +++ b/core/fpdfdoc/cpdf_filespec_unittest.cpp @@ -105,7 +105,7 @@ TEST(cpdf_filespec, GetFileName) { }; // Keyword fields in reverse order of precedence to retrieve the file name. const char* const keywords[5] = {"Unix", "Mac", "DOS", "F", "UF"}; - ScopedDict dict_obj(new CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>())); + ScopedDict dict_obj(new CPDF_Dictionary()); CPDF_FileSpec file_spec(dict_obj.get()); CFX_WideString file_name; for (int i = 0; i < 5; ++i) { @@ -155,7 +155,7 @@ TEST(cpdf_filespec, SetFileName) { EXPECT_TRUE(file_name == test_data.input); // Dictionary object. - ScopedDict dict_obj(new CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>())); + ScopedDict dict_obj(new CPDF_Dictionary()); CPDF_FileSpec file_spec2(dict_obj.get()); file_spec2.SetFileName(test_data.input); // Check internal object value. diff --git a/core/fpdfdoc/cpdf_formfield_unittest.cpp b/core/fpdfdoc/cpdf_formfield_unittest.cpp index 1fe5ee3838..42391d1491 100644 --- a/core/fpdfdoc/cpdf_formfield_unittest.cpp +++ b/core/fpdfdoc/cpdf_formfield_unittest.cpp @@ -12,29 +12,25 @@ TEST(cpdf_formfield, FPDF_GetFullName) { EXPECT_TRUE(name.IsEmpty()); CPDF_IndirectObjectHolder obj_holder; - CPDF_Dictionary* root = - new CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>()); + CPDF_Dictionary* root = new CPDF_Dictionary(); obj_holder.AddIndirectObject(root); root->SetNameFor("T", "foo"); name = FPDF_GetFullName(root); EXPECT_STREQ("foo", name.UTF8Encode().c_str()); - CPDF_Dictionary* dict1 = - new CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>()); + CPDF_Dictionary* dict1 = new CPDF_Dictionary(); root->SetReferenceFor("Parent", &obj_holder, obj_holder.AddIndirectObject(dict1)); dict1->SetNameFor("T", "bar"); name = FPDF_GetFullName(root); EXPECT_STREQ("bar.foo", name.UTF8Encode().c_str()); - CPDF_Dictionary* dict2 = - new CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>()); + CPDF_Dictionary* dict2 = new CPDF_Dictionary(); dict1->SetFor("Parent", dict2); name = FPDF_GetFullName(root); EXPECT_STREQ("bar.foo", name.UTF8Encode().c_str()); - CPDF_Dictionary* dict3 = - new CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>()); + CPDF_Dictionary* dict3 = new CPDF_Dictionary(); dict2->SetReferenceFor("Parent", &obj_holder, obj_holder.AddIndirectObject(dict3)); dict3->SetNameFor("T", "qux"); diff --git a/core/fxge/dib/fx_dib_engine_unittest.cpp b/core/fxge/dib/fx_dib_engine_unittest.cpp index 105c342a0f..b7c79c390a 100644 --- a/core/fxge/dib/fx_dib_engine_unittest.cpp +++ b/core/fxge/dib/fx_dib_engine_unittest.cpp @@ -16,7 +16,7 @@ TEST(CStretchEngine, OverflowInCtor) { FX_RECT clip_rect; std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> dict_obj( - new CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>())); + new CPDF_Dictionary()); dict_obj->SetFor("Width", new CPDF_Number(71000)); dict_obj->SetFor("Height", new CPDF_Number(12500)); std::unique_ptr<CPDF_Stream, ReleaseDeleter<CPDF_Stream>> stream( diff --git a/fpdfsdk/fpdfdoc_unittest.cpp b/fpdfsdk/fpdfdoc_unittest.cpp index e39b732272..70d136b890 100644 --- a/fpdfsdk/fpdfdoc_unittest.cpp +++ b/fpdfsdk/fpdfdoc_unittest.cpp @@ -64,7 +64,7 @@ class PDFDocTest : public testing::Test { m_pDoc = WrapUnique(new CPDF_TestPdfDocument()); m_pIndirectObjs = m_pDoc->GetHolder(); // Setup the root directory. - m_pRootObj.reset(new CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>())); + m_pRootObj.reset(new CPDF_Dictionary()); m_pDoc->SetRoot(m_pRootObj.get()); } @@ -79,8 +79,7 @@ class PDFDocTest : public testing::Test { std::vector<DictObjInfo> info; for (int i = 0; i < num; ++i) { // Objects created will be released by the document. - CPDF_Dictionary* obj( - new CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>())); + CPDF_Dictionary* obj = new CPDF_Dictionary(); info.push_back({m_pIndirectObjs->AddIndirectObject(obj), obj}); } return info; @@ -104,8 +103,7 @@ TEST_F(PDFDocTest, FindBookmark) { } { // Empty bookmark tree. - m_pRootObj->SetFor("Outlines", - new CPDF_Dictionary(CFX_WeakPtr<CFX_ByteStringPool>())); + m_pRootObj->SetFor("Outlines", new CPDF_Dictionary()); std::unique_ptr<unsigned short, pdfium::FreeDeleter> title = GetFPDFWideString(L""); EXPECT_EQ(nullptr, FPDFBookmark_Find(m_pDoc.get(), title.get())); |