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 <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 2503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2514 len = endStreamOffset; | 2514 len = endStreamOffset; |
2515 int numMarkers = ReadEOLMarkers(streamStartPos + endStreamOffset - 2); | 2515 int numMarkers = ReadEOLMarkers(streamStartPos + endStreamOffset - 2); |
2516 if (numMarkers == 2) { | 2516 if (numMarkers == 2) { |
2517 len -= 2; | 2517 len -= 2; |
2518 } else { | 2518 } else { |
2519 numMarkers = ReadEOLMarkers(streamStartPos + endStreamOffset - 1); | 2519 numMarkers = ReadEOLMarkers(streamStartPos + endStreamOffset - 1); |
2520 if (numMarkers == 1) { | 2520 if (numMarkers == 1) { |
2521 len -= 1; | 2521 len -= 1; |
2522 } | 2522 } |
2523 } | 2523 } |
2524 if (len <= 0) { | 2524 if (len < 0) { |
2525 return nullptr; | 2525 return nullptr; |
2526 } | 2526 } |
2527 pDict->SetAtInteger(FX_BSTRC("Length"), len); | 2527 pDict->SetAtInteger(FX_BSTRC("Length"), len); |
2528 } | 2528 } |
2529 m_Pos = streamStartPos; | 2529 m_Pos = streamStartPos; |
2530 } | 2530 } |
2531 if (len <= 0) { | 2531 if (len < 0) { |
2532 return nullptr; | 2532 return nullptr; |
2533 } | 2533 } |
2534 uint8_t* pData = FX_Alloc(uint8_t, len); | 2534 uint8_t* pData = nullptr; |
2535 ReadBlock(pData, len); | 2535 if (len > 0) { |
2536 if (pCryptoHandler) { | 2536 pData = FX_Alloc(uint8_t, len); |
2537 CFX_BinaryBuf dest_buf; | 2537 ReadBlock(pData, len); |
2538 dest_buf.EstimateSize(pCryptoHandler->DecryptGetSize(len)); | 2538 if (pCryptoHandler) { |
2539 void* context = pCryptoHandler->DecryptStart(objnum, gennum); | 2539 CFX_BinaryBuf dest_buf; |
2540 pCryptoHandler->DecryptStream(context, pData, len, dest_buf); | 2540 dest_buf.EstimateSize(pCryptoHandler->DecryptGetSize(len)); |
2541 pCryptoHandler->DecryptFinish(context, dest_buf); | 2541 void* context = pCryptoHandler->DecryptStart(objnum, gennum); |
2542 FX_Free(pData); | 2542 pCryptoHandler->DecryptStream(context, pData, len, dest_buf); |
2543 pData = dest_buf.GetBuffer(); | 2543 pCryptoHandler->DecryptFinish(context, dest_buf); |
2544 len = dest_buf.GetSize(); | 2544 FX_Free(pData); |
2545 dest_buf.DetachBuffer(); | 2545 pData = dest_buf.GetBuffer(); |
| 2546 len = dest_buf.GetSize(); |
| 2547 dest_buf.DetachBuffer(); |
| 2548 } |
2546 } | 2549 } |
2547 CPDF_Stream* pStream = new CPDF_Stream(pData, len, pDict); | 2550 CPDF_Stream* pStream = new CPDF_Stream(pData, len, pDict); |
2548 if (pContext) { | 2551 if (pContext) { |
2549 pContext->m_DataEnd = pContext->m_DataStart + len; | 2552 pContext->m_DataEnd = pContext->m_DataStart + len; |
2550 } | 2553 } |
2551 streamStartPos = m_Pos; | 2554 streamStartPos = m_Pos; |
2552 FXSYS_memset(m_WordBuffer, 0, ENDOBJ_LEN + 1); | 2555 FXSYS_memset(m_WordBuffer, 0, ENDOBJ_LEN + 1); |
2553 GetNextWord(); | 2556 GetNextWord(); |
2554 int numMarkers = ReadEOLMarkers(m_Pos); | 2557 int numMarkers = ReadEOLMarkers(m_Pos); |
2555 if (m_WordSize == ENDOBJ_LEN && numMarkers != 0 && | 2558 if (m_WordSize == ENDOBJ_LEN && numMarkers != 0 && |
(...skipping 2090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4646 return FALSE; | 4649 return FALSE; |
4647 } | 4650 } |
4648 CPDF_PageNode::~CPDF_PageNode() { | 4651 CPDF_PageNode::~CPDF_PageNode() { |
4649 int32_t iSize = m_childNode.GetSize(); | 4652 int32_t iSize = m_childNode.GetSize(); |
4650 for (int32_t i = 0; i < iSize; ++i) { | 4653 for (int32_t i = 0; i < iSize; ++i) { |
4651 CPDF_PageNode* pNode = (CPDF_PageNode*)m_childNode[i]; | 4654 CPDF_PageNode* pNode = (CPDF_PageNode*)m_childNode[i]; |
4652 delete pNode; | 4655 delete pNode; |
4653 } | 4656 } |
4654 m_childNode.RemoveAll(); | 4657 m_childNode.RemoveAll(); |
4655 } | 4658 } |
OLD | NEW |