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 "core/include/fpdfapi/fpdf_parser.h" | 7 #include "core/include/fpdfapi/fpdf_parser.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 FX_BOOL CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) { | 371 FX_BOOL CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) { |
372 if (!LoadCrossRefV4(xrefpos, 0, TRUE)) { | 372 if (!LoadCrossRefV4(xrefpos, 0, TRUE)) { |
373 return FALSE; | 373 return FALSE; |
374 } | 374 } |
375 m_pTrailer = LoadTrailerV4(); | 375 m_pTrailer = LoadTrailerV4(); |
376 if (!m_pTrailer) { | 376 if (!m_pTrailer) { |
377 return FALSE; | 377 return FALSE; |
378 } | 378 } |
379 | 379 |
380 int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size"); | 380 int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size"); |
381 if (xrefsize <= 0 || xrefsize > kMaxXRefSize) { | 381 if (xrefsize > 0 && xrefsize <= kMaxXRefSize) { |
382 return FALSE; | 382 ShrinkObjectMap(xrefsize); |
| 383 m_V5Type.SetSize(xrefsize); |
383 } | 384 } |
384 ShrinkObjectMap(xrefsize); | 385 |
385 m_V5Type.SetSize(xrefsize); | |
386 CFX_FileSizeArray CrossRefList; | 386 CFX_FileSizeArray CrossRefList; |
387 CFX_FileSizeArray XRefStreamList; | 387 CFX_FileSizeArray XRefStreamList; |
388 CrossRefList.Add(xrefpos); | 388 CrossRefList.Add(xrefpos); |
389 XRefStreamList.Add(GetDirectInteger(m_pTrailer, "XRefStm")); | 389 XRefStreamList.Add(GetDirectInteger(m_pTrailer, "XRefStm")); |
390 | 390 |
391 std::set<FX_FILESIZE> seen_xrefpos; | 391 std::set<FX_FILESIZE> seen_xrefpos; |
392 seen_xrefpos.insert(xrefpos); | 392 seen_xrefpos.insert(xrefpos); |
393 // When |m_pTrailer| doesn't have Prev entry or Prev entry value is not | 393 // When |m_pTrailer| doesn't have Prev entry or Prev entry value is not |
394 // numerical, GetDirectInteger() returns 0. Loading will end. | 394 // numerical, GetDirectInteger() returns 0. Loading will end. |
395 xrefpos = GetDirectInteger(m_pTrailer, "Prev"); | 395 xrefpos = GetDirectInteger(m_pTrailer, "Prev"); |
(...skipping 4598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4994 if (!m_pLinearizedDict) | 4994 if (!m_pLinearizedDict) |
4995 return -1; | 4995 return -1; |
4996 CPDF_Array* pRange = m_pLinearizedDict->GetArray("H"); | 4996 CPDF_Array* pRange = m_pLinearizedDict->GetArray("H"); |
4997 if (!pRange) | 4997 if (!pRange) |
4998 return -1; | 4998 return -1; |
4999 CPDF_Object* pStreamLen = pRange->GetElementValue(1); | 4999 CPDF_Object* pStreamLen = pRange->GetElementValue(1); |
5000 if (!pStreamLen) | 5000 if (!pStreamLen) |
5001 return -1; | 5001 return -1; |
5002 return pStreamLen->GetInteger(); | 5002 return pStreamLen->GetInteger(); |
5003 } | 5003 } |
OLD | NEW |