From b1ec280837cc6e1932754ef40de26d12b77aa910 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 25 May 2018 21:55:24 +0000 Subject: Add proper const/non-const versions of CPDF_Dictionary::GetDictFor(). BUG=pdfium:234 Change-Id: I6fde00c976ad4bb9cab632f465cf292f5b1da3d2 Reviewed-on: https://pdfium-review.googlesource.com/32914 Commit-Queue: Lei Zhang Reviewed-by: dsinclair --- core/fpdfapi/parser/cpdf_dictionary.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'core/fpdfapi/parser/cpdf_dictionary.cpp') diff --git a/core/fpdfapi/parser/cpdf_dictionary.cpp b/core/fpdfapi/parser/cpdf_dictionary.cpp index 1ede5e707a..5257a20586 100644 --- a/core/fpdfapi/parser/cpdf_dictionary.cpp +++ b/core/fpdfapi/parser/cpdf_dictionary.cpp @@ -130,7 +130,19 @@ bool CPDF_Dictionary::GetBooleanFor(const ByteString& key, return ToBoolean(p) ? p->GetInteger() != 0 : bDefault; } -CPDF_Dictionary* CPDF_Dictionary::GetDictFor(const ByteString& key) const { +const CPDF_Dictionary* CPDF_Dictionary::GetDictFor( + const ByteString& key) const { + CPDF_Object* p = GetDirectObjectFor(key); + if (!p) + return nullptr; + if (CPDF_Dictionary* pDict = p->AsDictionary()) + return pDict; + if (CPDF_Stream* pStream = p->AsStream()) + return pStream->GetDict(); + return nullptr; +} + +CPDF_Dictionary* CPDF_Dictionary::GetDictFor(const ByteString& key) { CPDF_Object* p = GetDirectObjectFor(key); if (!p) return nullptr; -- cgit v1.2.3