| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "../../../include/fpdfapi/fpdf_parser.h" | 7 #include "../../../include/fpdfapi/fpdf_parser.h" |
| 8 #include "../../../include/fpdfapi/fpdf_module.h" | 8 #include "../../../include/fpdfapi/fpdf_module.h" |
| 9 #include "../../../include/fpdfapi/fpdf_page.h" | 9 #include "../../../include/fpdfapi/fpdf_page.h" |
| 10 #include "../../../../third_party/numerics/safe_math.h" | 10 #include "../../../../third_party/numerics/safe_math.h" |
| (...skipping 2415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2426 ((CPDF_Reference*)pLenObj)->GetRefObjNum() != objnum))) { | 2426 ((CPDF_Reference*)pLenObj)->GetRefObjNum() != objnum))) { |
| 2427 len = pLenObj->GetInteger(); | 2427 len = pLenObj->GetInteger(); |
| 2428 } | 2428 } |
| 2429 | 2429 |
| 2430 ToNextLine(); | 2430 ToNextLine(); |
| 2431 FX_FILESIZE StreamStartPos = m_Pos; | 2431 FX_FILESIZE StreamStartPos = m_Pos; |
| 2432 if (pContext) { | 2432 if (pContext) { |
| 2433 pContext->m_DataStart = m_Pos; | 2433 pContext->m_DataStart = m_Pos; |
| 2434 } | 2434 } |
| 2435 | 2435 |
| 2436 base::CheckedNumeric<FX_FILESIZE> pos = m_Pos; | |
| 2437 pos += len; | |
| 2438 if (pos.IsValid() && pos.ValueOrDie() < m_FileLen) { | |
| 2439 m_Pos = pos.ValueOrDie(); | |
| 2440 } else { | |
| 2441 return NULL; | |
| 2442 } | |
| 2443 | |
| 2444 CPDF_CryptoHandler* pCryptoHandler = objnum == (FX_DWORD)m_MetadataObjnum ?
NULL : m_pCryptoHandler; | 2436 CPDF_CryptoHandler* pCryptoHandler = objnum == (FX_DWORD)m_MetadataObjnum ?
NULL : m_pCryptoHandler; |
| 2445 if (pCryptoHandler == NULL) { | 2437 if (pCryptoHandler == NULL) { |
| 2438 base::CheckedNumeric<FX_FILESIZE> pos = m_Pos; |
| 2439 pos += len; |
| 2440 if (pos.IsValid() && pos.ValueOrDie() < m_FileLen) { |
| 2441 m_Pos = pos.ValueOrDie(); |
| 2442 } |
| 2446 GetNextWord(); | 2443 GetNextWord(); |
| 2447 if (m_WordSize < 9 || FXSYS_memcmp32(m_WordBuffer, "endstream", 9)) { | 2444 if (m_WordSize < 9 || FXSYS_memcmp32(m_WordBuffer, "endstream", 9)) { |
| 2448 m_Pos = StreamStartPos; | 2445 m_Pos = StreamStartPos; |
| 2449 FX_FILESIZE offset = FindTag(FX_BSTRC("endstream"), 0); | 2446 FX_FILESIZE offset = FindTag(FX_BSTRC("endstream"), 0); |
| 2450 if (offset >= 0) { | 2447 if (offset >= 0) { |
| 2451 FX_FILESIZE curPos = m_Pos; | 2448 FX_FILESIZE curPos = m_Pos; |
| 2452 m_Pos = StreamStartPos; | 2449 m_Pos = StreamStartPos; |
| 2453 FX_FILESIZE endobjOffset = FindTag(FX_BSTRC("endobj"), 0); | 2450 FX_FILESIZE endobjOffset = FindTag(FX_BSTRC("endobj"), 0); |
| 2454 if (endobjOffset < offset && endobjOffset >= 0) { | 2451 if (endobjOffset < offset && endobjOffset >= 0) { |
| 2455 offset = endobjOffset; | 2452 offset = endobjOffset; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2466 } | 2463 } |
| 2467 len = (FX_DWORD)offset; | 2464 len = (FX_DWORD)offset; |
| 2468 pDict->SetAtInteger(FX_BSTRC("Length"), len); | 2465 pDict->SetAtInteger(FX_BSTRC("Length"), len); |
| 2469 } else { | 2466 } else { |
| 2470 m_Pos = StreamStartPos; | 2467 m_Pos = StreamStartPos; |
| 2471 if (FindTag(FX_BSTRC("endobj"), 0) < 0) { | 2468 if (FindTag(FX_BSTRC("endobj"), 0) < 0) { |
| 2472 return NULL; | 2469 return NULL; |
| 2473 } | 2470 } |
| 2474 } | 2471 } |
| 2475 } | 2472 } |
| 2473 m_Pos = StreamStartPos; |
| 2476 } | 2474 } |
| 2477 m_Pos = StreamStartPos; | |
| 2478 CPDF_Stream* pStream; | 2475 CPDF_Stream* pStream; |
| 2479 #if defined(_FPDFAPI_MINI_) && !defined(_FXCORE_FEATURE_ALL_) | 2476 #if defined(_FPDFAPI_MINI_) && !defined(_FXCORE_FEATURE_ALL_) |
| 2480 pStream = FX_NEW CPDF_Stream(m_pFileAccess, pCryptoHandler, m_HeaderOffset +
m_Pos, len, pDict, gennum); | 2477 pStream = FX_NEW CPDF_Stream(m_pFileAccess, pCryptoHandler, m_HeaderOffset +
m_Pos, len, pDict, gennum); |
| 2481 m_Pos += len; | 2478 m_Pos += len; |
| 2482 #else | 2479 #else |
| 2483 FX_LPBYTE pData = FX_Alloc(FX_BYTE, len); | 2480 FX_LPBYTE pData = FX_Alloc(FX_BYTE, len); |
| 2484 if (!pData) { | 2481 if (!pData) { |
| 2485 return NULL; | 2482 return NULL; |
| 2486 } | 2483 } |
| 2487 ReadBlock(pData, len); | 2484 ReadBlock(pData, len); |
| (...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4431 { | 4428 { |
| 4432 FX_INT32 iSize = m_childNode.GetSize(); | 4429 FX_INT32 iSize = m_childNode.GetSize(); |
| 4433 for (FX_INT32 i = 0; i < iSize; ++i) { | 4430 for (FX_INT32 i = 0; i < iSize; ++i) { |
| 4434 CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i]; | 4431 CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i]; |
| 4435 if (pNode) { | 4432 if (pNode) { |
| 4436 delete pNode; | 4433 delete pNode; |
| 4437 } | 4434 } |
| 4438 } | 4435 } |
| 4439 m_childNode.RemoveAll(); | 4436 m_childNode.RemoveAll(); |
| 4440 } | 4437 } |
| OLD | NEW |