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 "../../../include/fpdfapi/fpdf_parser.h" | 7 #include "../../../include/fpdfapi/fpdf_parser.h" |
8 #include "../../../include/fpdfapi/fpdf_module.h" | 8 #include "../../../include/fpdfapi/fpdf_module.h" |
9 #include "../../../include/fpdfapi/fpdf_page.h" | 9 #include "../../../include/fpdfapi/fpdf_page.h" |
10 #include "../../../../third_party/numerics/safe_math.h" | 10 #include "../../../../third_party/numerics/safe_math.h" |
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 return; | 1299 return; |
1300 } | 1300 } |
1301 FX_FILESIZE SavedPos = m_Syntax.SavePos(); | 1301 FX_FILESIZE SavedPos = m_Syntax.SavePos(); |
1302 m_Syntax.RestorePos(pos); | 1302 m_Syntax.RestorePos(pos); |
1303 FX_BOOL bIsNumber; | 1303 FX_BOOL bIsNumber; |
1304 CFX_ByteString word = m_Syntax.GetNextWord(bIsNumber); | 1304 CFX_ByteString word = m_Syntax.GetNextWord(bIsNumber); |
1305 if (!bIsNumber) { | 1305 if (!bIsNumber) { |
1306 m_Syntax.RestorePos(SavedPos); | 1306 m_Syntax.RestorePos(SavedPos); |
1307 return; | 1307 return; |
1308 } | 1308 } |
1309 FX_DWORD real_objnum = FXSYS_atoi(word); | 1309 FX_DWORD parser_objnum = FXSYS_atoi(word); |
1310 if (real_objnum && real_objnum != objnum) { | 1310 if (parser_objnum && parser_objnum != objnum) { |
1311 m_Syntax.RestorePos(SavedPos); | 1311 m_Syntax.RestorePos(SavedPos); |
1312 return; | 1312 return; |
1313 } | 1313 } |
1314 word = m_Syntax.GetNextWord(bIsNumber); | 1314 word = m_Syntax.GetNextWord(bIsNumber); |
1315 if (!bIsNumber) { | 1315 if (!bIsNumber) { |
1316 m_Syntax.RestorePos(SavedPos); | 1316 m_Syntax.RestorePos(SavedPos); |
1317 return; | 1317 return; |
1318 } | 1318 } |
1319 if (m_Syntax.GetKeyword() != FX_BSTRC("obj")) { | 1319 if (m_Syntax.GetKeyword() != FX_BSTRC("obj")) { |
1320 m_Syntax.RestorePos(SavedPos); | 1320 m_Syntax.RestorePos(SavedPos); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 FX_FILESIZE SavedPos = m_Syntax.SavePos(); | 1364 FX_FILESIZE SavedPos = m_Syntax.SavePos(); |
1365 m_Syntax.RestorePos(pos); | 1365 m_Syntax.RestorePos(pos); |
1366 FX_BOOL bIsNumber; | 1366 FX_BOOL bIsNumber; |
1367 CFX_ByteString word = m_Syntax.GetNextWord(bIsNumber); | 1367 CFX_ByteString word = m_Syntax.GetNextWord(bIsNumber); |
1368 if (!bIsNumber) { | 1368 if (!bIsNumber) { |
1369 m_Syntax.RestorePos(SavedPos); | 1369 m_Syntax.RestorePos(SavedPos); |
1370 return NULL; | 1370 return NULL; |
1371 } | 1371 } |
1372 FX_FILESIZE objOffset = m_Syntax.SavePos(); | 1372 FX_FILESIZE objOffset = m_Syntax.SavePos(); |
1373 objOffset -= word.GetLength(); | 1373 objOffset -= word.GetLength(); |
1374 FX_DWORD real_objnum = FXSYS_atoi(word); | 1374 FX_DWORD parser_objnum = FXSYS_atoi(word); |
1375 if (objnum && real_objnum != objnum) { | 1375 if (objnum && parser_objnum != objnum) { |
1376 m_Syntax.RestorePos(SavedPos); | 1376 m_Syntax.RestorePos(SavedPos); |
1377 return NULL; | 1377 return NULL; |
1378 } | 1378 } |
1379 word = m_Syntax.GetNextWord(bIsNumber); | 1379 word = m_Syntax.GetNextWord(bIsNumber); |
1380 if (!bIsNumber) { | 1380 if (!bIsNumber) { |
1381 m_Syntax.RestorePos(SavedPos); | 1381 m_Syntax.RestorePos(SavedPos); |
1382 return NULL; | 1382 return NULL; |
1383 } | 1383 } |
1384 FX_DWORD gennum = FXSYS_atoi(word); | 1384 FX_DWORD parser_gennum = FXSYS_atoi(word); |
1385 if (m_Syntax.GetKeyword() != FX_BSTRC("obj")) { | 1385 if (m_Syntax.GetKeyword() != FX_BSTRC("obj")) { |
1386 m_Syntax.RestorePos(SavedPos); | 1386 m_Syntax.RestorePos(SavedPos); |
1387 return NULL; | 1387 return NULL; |
1388 } | 1388 } |
1389 CPDF_Object* pObj = m_Syntax.GetObject(pObjList, objnum, gennum, 0, pContext
); | 1389 CPDF_Object* pObj = m_Syntax.GetObject(pObjList, objnum, parser_gennum, 0, p
Context); |
1390 FX_FILESIZE endOffset = m_Syntax.SavePos(); | 1390 FX_FILESIZE endOffset = m_Syntax.SavePos(); |
1391 CFX_ByteString bsWord = m_Syntax.GetKeyword(); | 1391 CFX_ByteString bsWord = m_Syntax.GetKeyword(); |
1392 if (bsWord == FX_BSTRC("endobj")) { | 1392 if (bsWord == FX_BSTRC("endobj")) { |
1393 endOffset = m_Syntax.SavePos(); | 1393 endOffset = m_Syntax.SavePos(); |
1394 } | 1394 } |
1395 m_Syntax.RestorePos(SavedPos); | 1395 m_Syntax.RestorePos(SavedPos); |
1396 if (pObj && !objnum) { | 1396 if (pObj) { |
1397 pObj->m_ObjNum = real_objnum; | 1397 if (!objnum) { |
1398 pObj->m_GenNum = gennum; | 1398 pObj->m_ObjNum = parser_objnum; |
| 1399 } |
| 1400 pObj->m_GenNum = parser_gennum; |
1399 } | 1401 } |
1400 return pObj; | 1402 return pObj; |
1401 } | 1403 } |
1402 CPDF_Object* CPDF_Parser::ParseIndirectObjectAtByStrict(CPDF_IndirectObjects* pO
bjList, FX_FILESIZE pos, FX_DWORD objnum, | 1404 CPDF_Object* CPDF_Parser::ParseIndirectObjectAtByStrict(CPDF_IndirectObjects* pO
bjList, FX_FILESIZE pos, FX_DWORD objnum, |
1403 struct PARSE_CONTEXT* pContext, FX_FILESIZE *pResultPos) | 1405 struct PARSE_CONTEXT* pContext, FX_FILESIZE *pResultPos) |
1404 { | 1406 { |
1405 FX_FILESIZE SavedPos = m_Syntax.SavePos(); | 1407 FX_FILESIZE SavedPos = m_Syntax.SavePos(); |
1406 m_Syntax.RestorePos(pos); | 1408 m_Syntax.RestorePos(pos); |
1407 FX_BOOL bIsNumber; | 1409 FX_BOOL bIsNumber; |
1408 CFX_ByteString word = m_Syntax.GetNextWord(bIsNumber); | 1410 CFX_ByteString word = m_Syntax.GetNextWord(bIsNumber); |
1409 if (!bIsNumber) { | 1411 if (!bIsNumber) { |
1410 m_Syntax.RestorePos(SavedPos); | 1412 m_Syntax.RestorePos(SavedPos); |
1411 return NULL; | 1413 return NULL; |
1412 } | 1414 } |
1413 FX_DWORD real_objnum = FXSYS_atoi(word); | 1415 FX_DWORD parser_objnum = FXSYS_atoi(word); |
1414 if (objnum && real_objnum != objnum) { | 1416 if (objnum && parser_objnum != objnum) { |
1415 m_Syntax.RestorePos(SavedPos); | 1417 m_Syntax.RestorePos(SavedPos); |
1416 return NULL; | 1418 return NULL; |
1417 } | 1419 } |
1418 word = m_Syntax.GetNextWord(bIsNumber); | 1420 word = m_Syntax.GetNextWord(bIsNumber); |
1419 if (!bIsNumber) { | 1421 if (!bIsNumber) { |
1420 m_Syntax.RestorePos(SavedPos); | 1422 m_Syntax.RestorePos(SavedPos); |
1421 return NULL; | 1423 return NULL; |
1422 } | 1424 } |
1423 FX_DWORD gennum = FXSYS_atoi(word); | 1425 FX_DWORD gennum = FXSYS_atoi(word); |
1424 if (m_Syntax.GetKeyword() != FX_BSTRC("obj")) { | 1426 if (m_Syntax.GetKeyword() != FX_BSTRC("obj")) { |
(...skipping 2028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3453 } | 3455 } |
3454 CPDF_Object * CPDF_DataAvail::ParseIndirectObjectAt(FX_FILESIZE pos, FX_DWOR
D objnum) | 3456 CPDF_Object * CPDF_DataAvail::ParseIndirectObjectAt(FX_FILESIZE pos, FX_DWOR
D objnum) |
3455 { | 3457 { |
3456 FX_FILESIZE SavedPos = m_syntaxParser.SavePos(); | 3458 FX_FILESIZE SavedPos = m_syntaxParser.SavePos(); |
3457 m_syntaxParser.RestorePos(pos); | 3459 m_syntaxParser.RestorePos(pos); |
3458 FX_BOOL bIsNumber; | 3460 FX_BOOL bIsNumber; |
3459 CFX_ByteString word = m_syntaxParser.GetNextWord(bIsNumber); | 3461 CFX_ByteString word = m_syntaxParser.GetNextWord(bIsNumber); |
3460 if (!bIsNumber) { | 3462 if (!bIsNumber) { |
3461 return NULL; | 3463 return NULL; |
3462 } | 3464 } |
3463 FX_DWORD real_objnum = FXSYS_atoi(word); | 3465 FX_DWORD parser_objnum = FXSYS_atoi(word); |
3464 if (objnum && real_objnum != objnum) { | 3466 if (objnum && parser_objnum != objnum) { |
3465 return NULL; | 3467 return NULL; |
3466 } | 3468 } |
3467 word = m_syntaxParser.GetNextWord(bIsNumber); | 3469 word = m_syntaxParser.GetNextWord(bIsNumber); |
3468 if (!bIsNumber) { | 3470 if (!bIsNumber) { |
3469 return NULL; | 3471 return NULL; |
3470 } | 3472 } |
3471 FX_DWORD gennum = FXSYS_atoi(word); | 3473 FX_DWORD gennum = FXSYS_atoi(word); |
3472 if (m_syntaxParser.GetKeyword() != FX_BSTRC("obj")) { | 3474 if (m_syntaxParser.GetKeyword() != FX_BSTRC("obj")) { |
3473 m_syntaxParser.RestorePos(SavedPos); | 3475 m_syntaxParser.RestorePos(SavedPos); |
3474 return NULL; | 3476 return NULL; |
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4425 { | 4427 { |
4426 FX_INT32 iSize = m_childNode.GetSize(); | 4428 FX_INT32 iSize = m_childNode.GetSize(); |
4427 for (FX_INT32 i = 0; i < iSize; ++i) { | 4429 for (FX_INT32 i = 0; i < iSize; ++i) { |
4428 CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i]; | 4430 CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i]; |
4429 if (pNode) { | 4431 if (pNode) { |
4430 delete pNode; | 4432 delete pNode; |
4431 } | 4433 } |
4432 } | 4434 } |
4433 m_childNode.RemoveAll(); | 4435 m_childNode.RemoveAll(); |
4434 } | 4436 } |
OLD | NEW |