From 937840e1722d1f2b77d80575d6e710d760662c9c Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 20 Oct 2015 13:30:34 -0400 Subject: Revert "Add type cast definitions for CPDF_Dictionary." This reverts commit 4816432671eef6467354aa252f22bb80acc315b7. Reason, broke the javascript_test Rendering PDF file /mnt/data/b/build/slave/linux/build/pdfium/out/Debug/gen/pdfium/testing/javascript/document_methods.pdf. Non-linearized path... FAILURE: document_methods.in; Command '['/mnt/data/b/build/slave/linux/build/pdfium/out/Debug/pdfium_test', '/mnt/data/b/build/slave/linux/build/pdfium/out/Debug/gen/pdfium/testing/javascript/document_methods.pdf']' returned non-zero exit status -11 BUG=pdfium:201 TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1412413002 . --- core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp | 29 ++++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp') diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp index 82bfbb56eb..19359ad7cf 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp @@ -70,11 +70,13 @@ void CFDF_Document::ParseStream(IFX_FileRead* pFile, FX_BOOL bOwnFile) { if (word != FX_BSTRC("trailer")) { break; } - if (CPDF_Dictionary* pMainDict = - ToDictionary(parser.GetObject(this, 0, 0, 0))) { - m_pRootDict = pMainDict->GetDict(FX_BSTRC("Root")); - pMainDict->Release(); + CPDF_Dictionary* pMainDict = + (CPDF_Dictionary*)parser.GetObject(this, 0, 0, 0); + if (pMainDict == NULL || pMainDict->GetType() != PDFOBJ_DICTIONARY) { + break; } + m_pRootDict = pMainDict->GetDict(FX_BSTRC("Root")); + pMainDict->Release(); break; } } @@ -140,17 +142,18 @@ void FPDF_FileSpec_SetWin32Path(CPDF_Object* pFileSpec, } if (pFileSpec->GetType() == PDFOBJ_STRING) { pFileSpec->SetString(CFX_ByteString::FromUnicode(result)); - } else if (CPDF_Dictionary* pFileDict = pFileSpec->AsDictionary()) { - pFileDict->SetAtString(FX_BSTRC("F"), CFX_ByteString::FromUnicode(result)); - pFileDict->SetAtString(FX_BSTRC("UF"), PDF_EncodeText(result)); - pFileDict->RemoveAt(FX_BSTRC("FS")); + } else if (pFileSpec->GetType() == PDFOBJ_DICTIONARY) { + ((CPDF_Dictionary*)pFileSpec) + ->SetAtString(FX_BSTRC("F"), CFX_ByteString::FromUnicode(result)); + ((CPDF_Dictionary*)pFileSpec) + ->SetAtString(FX_BSTRC("UF"), PDF_EncodeText(result)); + ((CPDF_Dictionary*)pFileSpec)->RemoveAt(FX_BSTRC("FS")); } } CFX_WideString FPDF_FileSpec_GetWin32Path(const CPDF_Object* pFileSpec) { CFX_WideString wsFileName; - if (!pFileSpec) { - wsFileName = CFX_WideString(); - } else if (const CPDF_Dictionary* pDict = pFileSpec->AsDictionary()) { + if (pFileSpec->GetType() == PDFOBJ_DICTIONARY) { + CPDF_Dictionary* pDict = (CPDF_Dictionary*)pFileSpec; wsFileName = pDict->GetUnicodeText(FX_BSTRC("UF")); if (wsFileName.IsEmpty()) { wsFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC("F"))); @@ -161,7 +164,9 @@ CFX_WideString FPDF_FileSpec_GetWin32Path(const CPDF_Object* pFileSpec) { if (wsFileName.IsEmpty() && pDict->KeyExist(FX_BSTRC("DOS"))) { wsFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC("DOS"))); } - } else { + } else if (!pFileSpec) + wsFileName = CFX_WideString(); + else { wsFileName = CFX_WideString::FromLocal(pFileSpec->GetString()); } if (wsFileName[0] != '/') { -- cgit v1.2.3