| Index: core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
 | 
| diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
 | 
| index 79a2bcde8af802fc3a4f079460afdd08aea54319..55c274ac0fe7f0cb8b17335ff7659443cfdf0f91 100644
 | 
| --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
 | 
| +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
 | 
| @@ -28,7 +28,7 @@ void CPDF_Object::Destroy() {
 | 
|        delete (CPDF_Array*)this;
 | 
|        break;
 | 
|      case PDFOBJ_DICTIONARY:
 | 
| -      delete (CPDF_Dictionary*)this;
 | 
| +      delete this->AsDictionary();
 | 
|        break;
 | 
|      case PDFOBJ_STREAM:
 | 
|        delete (CPDF_Stream*)this;
 | 
| @@ -138,7 +138,9 @@ int CPDF_Object::GetInteger() const {
 | 
|  CPDF_Dictionary* CPDF_Object::GetDict() const {
 | 
|    switch (m_Type) {
 | 
|      case PDFOBJ_DICTIONARY:
 | 
| -      return (CPDF_Dictionary*)this;
 | 
| +      // The method should be made non-const if we want to not be const.
 | 
| +      // See bug #234.
 | 
| +      return const_cast<CPDF_Dictionary*>(this->AsDictionary());
 | 
|      case PDFOBJ_STREAM:
 | 
|        return ((CPDF_Stream*)this)->GetDict();
 | 
|      case PDFOBJ_REFERENCE: {
 | 
| @@ -215,7 +217,7 @@ FX_BOOL CPDF_Object::IsIdentical(CPDF_Object* pOther) const {
 | 
|      case PDFOBJ_ARRAY:
 | 
|        return (((CPDF_Array*)this)->Identical((CPDF_Array*)pOther));
 | 
|      case PDFOBJ_DICTIONARY:
 | 
| -      return (((CPDF_Dictionary*)this)->Identical((CPDF_Dictionary*)pOther));
 | 
| +      return this->AsDictionary()->Identical(pOther->AsDictionary());
 | 
|      case PDFOBJ_NULL:
 | 
|        return TRUE;
 | 
|      case PDFOBJ_STREAM:
 | 
| @@ -264,7 +266,7 @@ CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect,
 | 
|      }
 | 
|      case PDFOBJ_DICTIONARY: {
 | 
|        CPDF_Dictionary* pCopy = new CPDF_Dictionary();
 | 
| -      CPDF_Dictionary* pThis = (CPDF_Dictionary*)this;
 | 
| +      const CPDF_Dictionary* pThis = this->AsDictionary();
 | 
|        FX_POSITION pos = pThis->m_Map.GetStartPosition();
 | 
|        while (pos) {
 | 
|          CFX_ByteString key;
 | 
| @@ -283,9 +285,9 @@ CPDF_Object* CPDF_Object::CloneInternal(FX_BOOL bDirect,
 | 
|        acc.LoadAllData(pThis, TRUE);
 | 
|        FX_DWORD streamSize = acc.GetSize();
 | 
|        CPDF_Dictionary* pDict = pThis->GetDict();
 | 
| -      if (pDict)
 | 
| -        pDict = (CPDF_Dictionary*)((CPDF_Object*)pDict)
 | 
| -                    ->CloneInternal(bDirect, visited);
 | 
| +      if (pDict) {
 | 
| +        pDict = ToDictionary(pDict->CloneInternal(bDirect, visited));
 | 
| +      }
 | 
|        return new CPDF_Stream(acc.DetachData(), streamSize, pDict);
 | 
|      }
 | 
|      case PDFOBJ_REFERENCE: {
 | 
| @@ -335,6 +337,14 @@ void CPDF_Object::SetUnicodeText(const FX_WCHAR* pUnicodes, int len) {
 | 
|    }
 | 
|  }
 | 
|  
 | 
| +CPDF_Dictionary* CPDF_Object::AsDictionary() {
 | 
| +  return IsDictionary() ? static_cast<CPDF_Dictionary*>(this) : nullptr;
 | 
| +}
 | 
| +
 | 
| +const CPDF_Dictionary* CPDF_Object::AsDictionary() const {
 | 
| +  return IsDictionary() ? static_cast<const CPDF_Dictionary*>(this) : nullptr;
 | 
| +}
 | 
| +
 | 
|  CPDF_Number::CPDF_Number(int value)
 | 
|      : CPDF_Object(PDFOBJ_NUMBER), m_bInteger(TRUE), m_Integer(value) {}
 | 
|  
 | 
| @@ -442,8 +452,8 @@ CPDF_Dictionary* CPDF_Array::GetDict(FX_DWORD i) const {
 | 
|    if (!p) {
 | 
|      return NULL;
 | 
|    }
 | 
| -  if (p->GetType() == PDFOBJ_DICTIONARY) {
 | 
| -    return (CPDF_Dictionary*)p;
 | 
| +  if (CPDF_Dictionary* pDict = p->AsDictionary()) {
 | 
| +    return pDict;
 | 
|    }
 | 
|    if (p->GetType() == PDFOBJ_STREAM) {
 | 
|      return ((CPDF_Stream*)p)->GetDict();
 | 
| @@ -663,8 +673,8 @@ CPDF_Dictionary* CPDF_Dictionary::GetDict(const CFX_ByteStringC& key) const {
 | 
|    if (!p) {
 | 
|      return nullptr;
 | 
|    }
 | 
| -  if (p->GetType() == PDFOBJ_DICTIONARY) {
 | 
| -    return (CPDF_Dictionary*)p;
 | 
| +  if (CPDF_Dictionary* pDict = p->AsDictionary()) {
 | 
| +    return pDict;
 | 
|    }
 | 
|    if (p->GetType() == PDFOBJ_STREAM) {
 | 
|      return ((CPDF_Stream*)p)->GetDict();
 | 
| 
 |