diff options
author | Artem Strygin <art-snake@yandex-team.ru> | 2017-09-04 17:01:41 +0300 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-09-05 16:04:08 +0000 |
commit | 4fde70e28c6aff85ad30a958823e658678f5cfb6 (patch) | |
tree | baaeb84083b6f245940f58ae2331ee08aad0527e /core/fpdfapi/parser/cpdf_object_walker_unittest.cpp | |
parent | 16b77c7176313531609a3a062d286f555c4710a1 (diff) | |
download | pdfium-4fde70e28c6aff85ad30a958823e658678f5cfb6.tar.xz |
Fix length field in dictionary on create stream
The CPDF_stream constructors were not setting the "Length" into the stream dictionary.
The "Length" was being set by the SetData methods.
This CL fixes the constructor to properly set the "Length" field.
Change-Id: Iee1bd7f7a096d415ab01ee3d2f3416e19e87ece9
Reviewed-on: https://pdfium-review.googlesource.com/13010
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Art Snake <art-snake@yandex-team.ru>
Diffstat (limited to 'core/fpdfapi/parser/cpdf_object_walker_unittest.cpp')
-rw-r--r-- | core/fpdfapi/parser/cpdf_object_walker_unittest.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/core/fpdfapi/parser/cpdf_object_walker_unittest.cpp b/core/fpdfapi/parser/cpdf_object_walker_unittest.cpp index 66c559d3ca..c5ffe844ad 100644 --- a/core/fpdfapi/parser/cpdf_object_walker_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_object_walker_unittest.cpp @@ -38,6 +38,8 @@ std::string Walk(CPDF_Object* object) { result << " Stream"; else if (obj->IsReference()) result << " Ref"; + else if (obj->IsNumber()) + result << " Num"; else if (obj->IsNull()) result << " Null"; else @@ -72,13 +74,14 @@ TEST(CPDF_ObjectWalkerTest, CombinedObject) { array->Add(pdfium::MakeUnique<CPDF_Stream>( nullptr, 0, pdfium::MakeUnique<CPDF_Dictionary>())); dict->SetFor("3", std::move(array)); - EXPECT_EQ(Walk(dict.get()), "Dict Str Bool Arr Ref Null Stream Dict"); + // The last number for stream length. + EXPECT_EQ(Walk(dict.get()), "Dict Str Bool Arr Ref Null Stream Dict Num"); } TEST(CPDF_ObjectWalkerTest, GetParent) { - auto level_4 = pdfium::MakeUnique<CPDF_Null>(); + auto level_4 = pdfium::MakeUnique<CPDF_Number>(0); auto level_3 = pdfium::MakeUnique<CPDF_Dictionary>(); - level_3->SetFor("AnyObj", std::move(level_4)); + level_3->SetFor("Length", std::move(level_4)); auto level_2 = pdfium::MakeUnique<CPDF_Stream>(nullptr, 0, std::move(level_3)); auto level_1 = pdfium::MakeUnique<CPDF_Array>(); @@ -86,7 +89,7 @@ TEST(CPDF_ObjectWalkerTest, GetParent) { auto level_0 = pdfium::MakeUnique<CPDF_Dictionary>(); level_0->SetFor("Array", std::move(level_1)); - // We have <</Array [ stream( << /AnyObj null >>) ]>> + // We have <</Array [ stream( << /Length 0 >>) ]>> // In this case each step will increase depth. // And on each step the prev object should be parent for current. const CPDF_Object* cur_parent = nullptr; |