Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(607)

Side by Side Diff: core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp

Issue 1549073002: Fix crash from commit f6dafc9. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "editint.h" 7 #include "editint.h"
8 8
9 #include "core/include/fxcrt/fx_ext.h" 9 #include "core/include/fxcrt/fx_ext.h"
10 #include "core/include/fpdfapi/fpdf_serial.h" 10 #include "core/include/fpdfapi/fpdf_serial.h"
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 m_Offset += size; 1312 m_Offset += size;
1313 if (AppendObjectNumberToXRef(objnum) < 0) { 1313 if (AppendObjectNumberToXRef(objnum) < 0) {
1314 return -1; 1314 return -1;
1315 } 1315 }
1316 } 1316 }
1317 FX_Free(pBuffer); 1317 FX_Free(pBuffer);
1318 } 1318 }
1319 return 1; 1319 return 1;
1320 } 1320 }
1321 int32_t CPDF_Creator::WriteOldObjs(IFX_Pause* pPause) { 1321 int32_t CPDF_Creator::WriteOldObjs(IFX_Pause* pPause) {
1322 FX_DWORD nLastObjNum = m_pParser->GetLastObjNum(); 1322 FX_DWORD nLastObjNum = m_pParser->GetLastObjNum();
Wei Li 2015/12/24 18:09:14 Need to check here too?
Lei Zhang 2015/12/24 18:53:42 It was already dereferencing |m_pParser| without a
1323 if (!m_pParser->IsValidObjectNumber(nLastObjNum)) 1323 if (!m_pParser->IsValidObjectNumber(nLastObjNum))
1324 return 0; 1324 return 0;
1325 1325
1326 FX_DWORD objnum = (FX_DWORD)(uintptr_t)m_Pos; 1326 FX_DWORD objnum = (FX_DWORD)(uintptr_t)m_Pos;
1327 for (; objnum <= nLastObjNum; ++objnum) { 1327 for (; objnum <= nLastObjNum; ++objnum) {
1328 int32_t iRet = WriteOldIndirectObject(objnum); 1328 int32_t iRet = WriteOldIndirectObject(objnum);
1329 if (iRet < 0) 1329 if (iRet < 0)
1330 return iRet; 1330 return iRet;
1331 1331
1332 if (!iRet) 1332 if (!iRet)
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 CPDF_Object* pObj; 1398 CPDF_Object* pObj;
1399 m_pDocument->m_IndirectObjs.GetNextAssoc(pos, (void*&)key, (void*&)pObj); 1399 m_pDocument->m_IndirectObjs.GetNextAssoc(pos, (void*&)key, (void*&)pObj);
1400 FX_DWORD objnum = (FX_DWORD)key; 1400 FX_DWORD objnum = (FX_DWORD)key;
1401 if (pObj->GetObjNum() == -1) { 1401 if (pObj->GetObjNum() == -1) {
1402 continue; 1402 continue;
1403 } 1403 }
1404 if (bIncremental) { 1404 if (bIncremental) {
1405 if (!pObj->IsModified()) { 1405 if (!pObj->IsModified()) {
1406 continue; 1406 continue;
1407 } 1407 }
1408 } else if (m_pParser->IsValidObjectNumber(objnum) && 1408 } else if (m_pParser && m_pParser->IsValidObjectNumber(objnum) &&
1409 m_pParser->m_V5Type[objnum]) { 1409 m_pParser->m_V5Type[objnum]) {
1410 continue; 1410 continue;
1411 } 1411 }
1412 AppendNewObjNum(objnum); 1412 AppendNewObjNum(objnum);
1413 } 1413 }
1414 int32_t iCount = m_NewObjNumArray.GetSize(); 1414 int32_t iCount = m_NewObjNumArray.GetSize();
1415 if (iCount == 0) { 1415 if (iCount == 0) {
1416 return; 1416 return;
1417 } 1417 }
1418 int32_t i = 0; 1418 int32_t i = 0;
1419 FX_DWORD dwStartObjNum = 0; 1419 FX_DWORD dwStartObjNum = 0;
1420 FX_BOOL bCrossRefValid = m_pParser && m_pParser->GetLastXRefOffset() > 0; 1420 FX_BOOL bCrossRefValid = m_pParser && m_pParser->GetLastXRefOffset() > 0;
1421 while (i < iCount) { 1421 while (i < iCount) {
1422 dwStartObjNum = m_NewObjNumArray.ElementAt(i); 1422 dwStartObjNum = m_NewObjNumArray.ElementAt(i);
1423 if ((bIncremental && (bNoOriginal || bCrossRefValid)) || 1423 if ((bIncremental && (bNoOriginal || bCrossRefValid)) ||
1424 !m_ObjectOffset.GetPtrAt(dwStartObjNum)) { 1424 !m_ObjectOffset.GetPtrAt(dwStartObjNum)) {
1425 break; 1425 break;
1426 } 1426 }
1427 i++; 1427 i++;
1428 } 1428 }
1429 if (i >= iCount) { 1429 if (i >= iCount) {
1430 return; 1430 return;
1431 } 1431 }
1432 FX_DWORD dwLastObjNum = dwStartObjNum; 1432 FX_DWORD dwLastObjNum = dwStartObjNum;
1433 i++; 1433 i++;
1434 FX_BOOL bNewStart = FALSE; 1434 FX_BOOL bNewStart = FALSE;
1435 for (; i < iCount; i++) { 1435 for (; i < iCount; i++) {
1436 FX_DWORD dwCurObjNum = m_NewObjNumArray.ElementAt(i); 1436 FX_DWORD dwCurObjNum = m_NewObjNumArray.ElementAt(i);
1437 bool bExist = m_pParser->IsValidObjectNumber(dwCurObjNum) && 1437 bool bExist = m_pParser && m_pParser->IsValidObjectNumber(dwCurObjNum) &&
1438 m_ObjectOffset.GetPtrAt(dwCurObjNum); 1438 m_ObjectOffset.GetPtrAt(dwCurObjNum);
1439 if (bExist || dwCurObjNum - dwLastObjNum > 1) { 1439 if (bExist || dwCurObjNum - dwLastObjNum > 1) {
1440 if (!bNewStart) { 1440 if (!bNewStart) {
1441 m_ObjectOffset.Add(dwStartObjNum, dwLastObjNum - dwStartObjNum + 1); 1441 m_ObjectOffset.Add(dwStartObjNum, dwLastObjNum - dwStartObjNum + 1);
1442 m_ObjectSize.Add(dwStartObjNum, dwLastObjNum - dwStartObjNum + 1); 1442 m_ObjectSize.Add(dwStartObjNum, dwLastObjNum - dwStartObjNum + 1);
1443 } 1443 }
1444 dwStartObjNum = dwCurObjNum; 1444 dwStartObjNum = dwCurObjNum;
1445 } 1445 }
1446 if (bNewStart) { 1446 if (bNewStart) {
1447 dwStartObjNum = dwCurObjNum; 1447 dwStartObjNum = dwCurObjNum;
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 m_bNewCrypto = FALSE; 2104 m_bNewCrypto = FALSE;
2105 if (!m_bStandardSecurity) { 2105 if (!m_bStandardSecurity) {
2106 return; 2106 return;
2107 } 2107 }
2108 if (m_pEncryptDict) { 2108 if (m_pEncryptDict) {
2109 m_pEncryptDict->Release(); 2109 m_pEncryptDict->Release();
2110 m_pEncryptDict = NULL; 2110 m_pEncryptDict = NULL;
2111 } 2111 }
2112 m_bStandardSecurity = FALSE; 2112 m_bStandardSecurity = FALSE;
2113 } 2113 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698