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) { |
jun_fang
2015/10/08 09:19:52
Relax too?
Lei Zhang
2015/10/08 17:33:08
Done.
| |
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 pData = FX_Alloc(uint8_t, len); | |
2537 ReadBlock(pData, len); | |
2538 } | |
2536 if (pCryptoHandler) { | 2539 if (pCryptoHandler) { |
jun_fang
2015/10/08 09:19:52
If pData is nullptr, there is no data to be decryp
Lei Zhang
2015/10/08 17:21:49
Ok. Since |pData| can only be a nullptr when len =
| |
2537 CFX_BinaryBuf dest_buf; | 2540 CFX_BinaryBuf dest_buf; |
2538 dest_buf.EstimateSize(pCryptoHandler->DecryptGetSize(len)); | 2541 dest_buf.EstimateSize(pCryptoHandler->DecryptGetSize(len)); |
2539 void* context = pCryptoHandler->DecryptStart(objnum, gennum); | 2542 void* context = pCryptoHandler->DecryptStart(objnum, gennum); |
2540 pCryptoHandler->DecryptStream(context, pData, len, dest_buf); | 2543 pCryptoHandler->DecryptStream(context, pData, len, dest_buf); |
2541 pCryptoHandler->DecryptFinish(context, dest_buf); | 2544 pCryptoHandler->DecryptFinish(context, dest_buf); |
2542 FX_Free(pData); | 2545 FX_Free(pData); |
2543 pData = dest_buf.GetBuffer(); | 2546 pData = dest_buf.GetBuffer(); |
2544 len = dest_buf.GetSize(); | 2547 len = dest_buf.GetSize(); |
2545 dest_buf.DetachBuffer(); | 2548 dest_buf.DetachBuffer(); |
2546 } | 2549 } |
(...skipping 2099 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 |