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 "parser_int.h" | 7 #include "parser_int.h" |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 2334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2345 FX_BOOL bSearchForKeyword = TRUE; | 2345 FX_BOOL bSearchForKeyword = TRUE; |
2346 if (len >= 0) { | 2346 if (len >= 0) { |
2347 pdfium::base::CheckedNumeric<FX_FILESIZE> pos = m_Pos; | 2347 pdfium::base::CheckedNumeric<FX_FILESIZE> pos = m_Pos; |
2348 pos += len; | 2348 pos += len; |
2349 if (pos.IsValid() && pos.ValueOrDie() < m_FileLen) { | 2349 if (pos.IsValid() && pos.ValueOrDie() < m_FileLen) { |
2350 m_Pos = pos.ValueOrDie(); | 2350 m_Pos = pos.ValueOrDie(); |
2351 } | 2351 } |
2352 m_Pos += ReadEOLMarkers(m_Pos); | 2352 m_Pos += ReadEOLMarkers(m_Pos); |
2353 FXSYS_memset(m_WordBuffer, 0, ENDSTREAM_LEN + 1); | 2353 FXSYS_memset(m_WordBuffer, 0, ENDSTREAM_LEN + 1); |
2354 GetNextWord(); | 2354 GetNextWord(); |
2355 if (FXSYS_memcmp(m_WordBuffer, "endstream", ENDSTREAM_LEN) == 0 && | 2355 // Earlier version of PDF specification doesn't require EOL marker before |
2356 IsWholeWord(m_Pos - ENDSTREAM_LEN, m_FileLen, | 2356 // 'endstream' keyword. If keyword 'endstream' follows the bytes in |
2357 FX_BSTRC("endstream").GetPtr(), ENDSTREAM_LEN, TRUE)) { | 2357 // specified length, it signals the end of stream. |
| 2358 if (FXSYS_memcmp(m_WordBuffer, "endstream", ENDSTREAM_LEN) == 0) |
2358 bSearchForKeyword = FALSE; | 2359 bSearchForKeyword = FALSE; |
2359 } | |
2360 } | 2360 } |
2361 if (bSearchForKeyword) { | 2361 if (bSearchForKeyword) { |
2362 // If len is not available, len needs to be calculated | 2362 // If len is not available, len needs to be calculated |
2363 // by searching the keywords "endstream" or "endobj". | 2363 // by searching the keywords "endstream" or "endobj". |
2364 m_Pos = streamStartPos; | 2364 m_Pos = streamStartPos; |
2365 FX_FILESIZE endStreamOffset = 0; | 2365 FX_FILESIZE endStreamOffset = 0; |
2366 while (endStreamOffset >= 0) { | 2366 while (endStreamOffset >= 0) { |
2367 endStreamOffset = FindTag(FX_BSTRC("endstream"), 0); | 2367 endStreamOffset = FindTag(FX_BSTRC("endstream"), 0); |
2368 if (endStreamOffset < 0) { | 2368 if (endStreamOffset < 0) { |
2369 // Can't find any "endstream". | 2369 // Can't find any "endstream". |
(...skipping 2568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4938 if (!m_pLinearizedDict) | 4938 if (!m_pLinearizedDict) |
4939 return -1; | 4939 return -1; |
4940 CPDF_Array* pRange = m_pLinearizedDict->GetArray(FX_BSTRC("H")); | 4940 CPDF_Array* pRange = m_pLinearizedDict->GetArray(FX_BSTRC("H")); |
4941 if (!pRange) | 4941 if (!pRange) |
4942 return -1; | 4942 return -1; |
4943 CPDF_Object* pStreamLen = pRange->GetElementValue(1); | 4943 CPDF_Object* pStreamLen = pRange->GetElementValue(1); |
4944 if (!pStreamLen) | 4944 if (!pStreamLen) |
4945 return -1; | 4945 return -1; |
4946 return pStreamLen->GetInteger(); | 4946 return pStreamLen->GetInteger(); |
4947 } | 4947 } |
OLD | NEW |