OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/fpdfapi/fpdf_parser/cpdf_boolean.h" | 5 #include "core/fpdfapi/fpdf_parser/cpdf_boolean.h" |
6 #include "core/fpdfapi/fpdf_parser/cpdf_null.h" | 6 #include "core/fpdfapi/fpdf_parser/cpdf_null.h" |
7 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
8 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 8 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_name.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_name.h" |
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" |
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 EXPECT_EQ(nullptr, cloned_dict->AsDictionary()->GetObjectFor("arr")); | 806 EXPECT_EQ(nullptr, cloned_dict->AsDictionary()->GetObjectFor("arr")); |
807 } | 807 } |
808 { | 808 { |
809 CPDF_IndirectObjectHolder objects_holder; | 809 CPDF_IndirectObjectHolder objects_holder; |
810 // Create an object with a reference loop. | 810 // Create an object with a reference loop. |
811 CPDF_Dictionary* dict_obj = new CPDF_Dictionary; | 811 CPDF_Dictionary* dict_obj = new CPDF_Dictionary; |
812 CPDF_Array* arr_obj = new CPDF_Array; | 812 CPDF_Array* arr_obj = new CPDF_Array; |
813 objects_holder.AddIndirectObject(dict_obj); | 813 objects_holder.AddIndirectObject(dict_obj); |
814 EXPECT_EQ(1u, dict_obj->GetObjNum()); | 814 EXPECT_EQ(1u, dict_obj->GetObjNum()); |
815 dict_obj->SetFor("arr", arr_obj); | 815 dict_obj->SetFor("arr", arr_obj); |
816 arr_obj->InsertAt(0, dict_obj, &objects_holder); | 816 arr_obj->InsertAt( |
| 817 0, new CPDF_Reference(&objects_holder, dict_obj->GetObjNum())); |
817 CPDF_Object* elem0 = arr_obj->GetObjectAt(0); | 818 CPDF_Object* elem0 = arr_obj->GetObjectAt(0); |
818 ASSERT_TRUE(elem0); | 819 ASSERT_TRUE(elem0); |
819 ASSERT_TRUE(elem0->IsReference()); | 820 ASSERT_TRUE(elem0->IsReference()); |
820 EXPECT_EQ(1u, elem0->AsReference()->GetRefObjNum()); | 821 EXPECT_EQ(1u, elem0->AsReference()->GetRefObjNum()); |
821 EXPECT_EQ(dict_obj, elem0->AsReference()->GetDirect()); | 822 EXPECT_EQ(dict_obj, elem0->AsReference()->GetDirect()); |
822 | 823 |
823 // Clone this object to see whether stack overflow will be triggered. | 824 // Clone this object to see whether stack overflow will be triggered. |
824 ScopedDict cloned_dict(ToDictionary(dict_obj->CloneDirectObject())); | 825 ScopedDict cloned_dict(ToDictionary(dict_obj->CloneDirectObject())); |
825 // Cloned object should be the same as the original. | 826 // Cloned object should be the same as the original. |
826 ASSERT_TRUE(cloned_dict); | 827 ASSERT_TRUE(cloned_dict); |
827 CPDF_Object* cloned_arr = cloned_dict->GetObjectFor("arr"); | 828 CPDF_Object* cloned_arr = cloned_dict->GetObjectFor("arr"); |
828 ASSERT_TRUE(cloned_arr); | 829 ASSERT_TRUE(cloned_arr); |
829 ASSERT_TRUE(cloned_arr->IsArray()); | 830 ASSERT_TRUE(cloned_arr->IsArray()); |
830 EXPECT_EQ(1u, cloned_arr->AsArray()->GetCount()); | 831 EXPECT_EQ(1u, cloned_arr->AsArray()->GetCount()); |
831 // Recursively referenced object is not cloned. | 832 // Recursively referenced object is not cloned. |
832 EXPECT_EQ(nullptr, cloned_arr->AsArray()->GetObjectAt(0)); | 833 EXPECT_EQ(nullptr, cloned_arr->AsArray()->GetObjectAt(0)); |
833 } | 834 } |
834 } | 835 } |
OLD | NEW |