OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/fpdfapi/page/cpdf_streamparser.h" | 7 #include "core/fpdfapi/page/cpdf_streamparser.h" |
8 | 8 |
9 #include <limits.h> | 9 #include <limits.h> |
10 | 10 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 std::unique_ptr<uint8_t, FxFreeDeleter> pData; | 181 std::unique_ptr<uint8_t, FxFreeDeleter> pData; |
182 uint32_t dwStreamSize; | 182 uint32_t dwStreamSize; |
183 if (Decoder.IsEmpty()) { | 183 if (Decoder.IsEmpty()) { |
184 if (OrigSize > m_Size - m_Pos) | 184 if (OrigSize > m_Size - m_Pos) |
185 OrigSize = m_Size - m_Pos; | 185 OrigSize = m_Size - m_Pos; |
186 pData.reset(FX_Alloc(uint8_t, OrigSize)); | 186 pData.reset(FX_Alloc(uint8_t, OrigSize)); |
187 FXSYS_memcpy(pData.get(), m_pBuf + m_Pos, OrigSize); | 187 FXSYS_memcpy(pData.get(), m_pBuf + m_Pos, OrigSize); |
188 dwStreamSize = OrigSize; | 188 dwStreamSize = OrigSize; |
189 m_Pos += OrigSize; | 189 m_Pos += OrigSize; |
190 } else { | 190 } else { |
191 uint8_t* pIgnore; | 191 uint8_t* pIgnore = nullptr; |
192 uint32_t dwDestSize = OrigSize; | 192 uint32_t dwDestSize = OrigSize; |
193 dwStreamSize = | 193 dwStreamSize = |
194 PDF_DecodeInlineStream(m_pBuf + m_Pos, m_Size - m_Pos, width, height, | 194 PDF_DecodeInlineStream(m_pBuf + m_Pos, m_Size - m_Pos, width, height, |
195 Decoder, pParam, pIgnore, dwDestSize); | 195 Decoder, pParam, pIgnore, dwDestSize); |
196 FX_Free(pIgnore); | 196 FX_Free(pIgnore); |
197 if (static_cast<int>(dwStreamSize) < 0) | 197 if (static_cast<int>(dwStreamSize) < 0) |
198 return nullptr; | 198 return nullptr; |
199 | 199 |
200 uint32_t dwSavePos = m_Pos; | 200 uint32_t dwSavePos = m_Pos; |
201 m_Pos += dwStreamSize; | 201 m_Pos += dwStreamSize; |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 | 597 |
598 if (buf.GetLength() > kMaxStringLength) | 598 if (buf.GetLength() > kMaxStringLength) |
599 return CFX_ByteString(buf.GetBuffer(), kMaxStringLength); | 599 return CFX_ByteString(buf.GetBuffer(), kMaxStringLength); |
600 | 600 |
601 return buf.MakeString(); | 601 return buf.MakeString(); |
602 } | 602 } |
603 | 603 |
604 bool CPDF_StreamParser::PositionIsInBounds() const { | 604 bool CPDF_StreamParser::PositionIsInBounds() const { |
605 return m_Pos < m_Size; | 605 return m_Pos < m_Size; |
606 } | 606 } |
OLD | NEW |