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

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

Issue 1542363002: Merge to XFA: Fix crash from commit f6dafc9. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
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 1387 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