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

Side by Side Diff: core/fpdfdoc/cpdf_interform.cpp

Issue 2250533002: Fix stack overflow in object Clone() functions (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase again Created 4 years, 4 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 | « core/fpdfapi/fpdf_parser/include/cpdf_string.h ('k') | fpdfsdk/fpdfppo.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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 <vector> 7 #include <vector>
8 8
9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
10 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h" 10 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h"
(...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 if (pFieldDict->KeyExist("Ff")) { 1396 if (pFieldDict->KeyExist("Ff")) {
1397 CPDF_Object* pFfValue = pFieldDict->GetDirectObjectBy("Ff"); 1397 CPDF_Object* pFfValue = pFieldDict->GetDirectObjectBy("Ff");
1398 if (pFfValue) 1398 if (pFfValue)
1399 pParent->SetAt("Ff", pFfValue->Clone()); 1399 pParent->SetAt("Ff", pFfValue->Clone());
1400 } 1400 }
1401 } 1401 }
1402 1402
1403 pField = new CPDF_FormField(this, pParent); 1403 pField = new CPDF_FormField(this, pParent);
1404 CPDF_Object* pTObj = pDict->GetObjectBy("T"); 1404 CPDF_Object* pTObj = pDict->GetObjectBy("T");
1405 if (ToReference(pTObj)) { 1405 if (ToReference(pTObj)) {
1406 CPDF_Object* pClone = pTObj->Clone(TRUE); 1406 CPDF_Object* pClone = pTObj->CloneDirectObject();
1407 if (pClone) 1407 if (pClone)
1408 pDict->SetAt("T", pClone); 1408 pDict->SetAt("T", pClone);
1409 else 1409 else
1410 pDict->SetAtName("T", ""); 1410 pDict->SetAtName("T", "");
1411 } 1411 }
1412 m_pFieldTree->SetField(csWName, pField); 1412 m_pFieldTree->SetField(csWName, pField);
1413 } 1413 }
1414 1414
1415 CPDF_Array* pKids = pFieldDict->GetArrayBy("Kids"); 1415 CPDF_Array* pKids = pFieldDict->GetArrayBy("Kids");
1416 if (!pKids) { 1416 if (!pKids) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 CFX_WideString csExport = pField->GetCheckValue(FALSE); 1528 CFX_WideString csExport = pField->GetCheckValue(FALSE);
1529 CFX_ByteString csBExport = PDF_EncodeText(csExport); 1529 CFX_ByteString csBExport = PDF_EncodeText(csExport);
1530 CPDF_Object* pOpt = FPDF_GetFieldAttr(pField->m_pDict, "Opt"); 1530 CPDF_Object* pOpt = FPDF_GetFieldAttr(pField->m_pDict, "Opt");
1531 if (pOpt) 1531 if (pOpt)
1532 pFieldDict->SetAtString("V", csBExport); 1532 pFieldDict->SetAtString("V", csBExport);
1533 else 1533 else
1534 pFieldDict->SetAtName("V", csBExport); 1534 pFieldDict->SetAtName("V", csBExport);
1535 } else { 1535 } else {
1536 CPDF_Object* pV = FPDF_GetFieldAttr(pField->m_pDict, "V"); 1536 CPDF_Object* pV = FPDF_GetFieldAttr(pField->m_pDict, "V");
1537 if (pV) 1537 if (pV)
1538 pFieldDict->SetAt("V", pV->Clone(TRUE)); 1538 pFieldDict->SetAt("V", pV->CloneDirectObject());
1539 } 1539 }
1540 pFields->Add(pFieldDict); 1540 pFields->Add(pFieldDict);
1541 } 1541 }
1542 } 1542 }
1543 return pDoc; 1543 return pDoc;
1544 } 1544 }
1545 1545
1546 void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, 1546 void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict,
1547 const CFX_WideString& parent_name, 1547 const CFX_WideString& parent_name,
1548 FX_BOOL bNotify, 1548 FX_BOOL bNotify,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 iRet = m_pFormNotify->BeforeValueChange(pField, csWValue); 1580 iRet = m_pFormNotify->BeforeValueChange(pField, csWValue);
1581 1581
1582 if (iRet < 0) 1582 if (iRet < 0)
1583 return; 1583 return;
1584 } 1584 }
1585 1585
1586 pField->SetValue(csWValue); 1586 pField->SetValue(csWValue);
1587 CPDF_FormField::Type eType = pField->GetType(); 1587 CPDF_FormField::Type eType = pField->GetType();
1588 if ((eType == CPDF_FormField::ListBox || eType == CPDF_FormField::ComboBox) && 1588 if ((eType == CPDF_FormField::ListBox || eType == CPDF_FormField::ComboBox) &&
1589 pFieldDict->KeyExist("Opt")) { 1589 pFieldDict->KeyExist("Opt")) {
1590 pField->m_pDict->SetAt("Opt", 1590 pField->m_pDict->SetAt(
1591 pFieldDict->GetDirectObjectBy("Opt")->Clone(TRUE)); 1591 "Opt", pFieldDict->GetDirectObjectBy("Opt")->CloneDirectObject());
1592 } 1592 }
1593 1593
1594 if (bNotify && m_pFormNotify) { 1594 if (bNotify && m_pFormNotify) {
1595 if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON) 1595 if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON)
1596 m_pFormNotify->AfterCheckedStatusChange(pField); 1596 m_pFormNotify->AfterCheckedStatusChange(pField);
1597 else if (iType == FIELDTYPE_LISTBOX) 1597 else if (iType == FIELDTYPE_LISTBOX)
1598 m_pFormNotify->AfterSelectionChange(pField); 1598 m_pFormNotify->AfterSelectionChange(pField);
1599 else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD) 1599 else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD)
1600 m_pFormNotify->AfterValueChange(pField); 1600 m_pFormNotify->AfterValueChange(pField);
1601 } 1601 }
(...skipping 24 matching lines...) Expand all
1626 FDF_ImportField(pField, L"", bNotify); 1626 FDF_ImportField(pField, L"", bNotify);
1627 } 1627 }
1628 if (bNotify && m_pFormNotify) 1628 if (bNotify && m_pFormNotify)
1629 m_pFormNotify->AfterFormImportData(this); 1629 m_pFormNotify->AfterFormImportData(this);
1630 return TRUE; 1630 return TRUE;
1631 } 1631 }
1632 1632
1633 void CPDF_InterForm::SetFormNotify(IPDF_FormNotify* pNotify) { 1633 void CPDF_InterForm::SetFormNotify(IPDF_FormNotify* pNotify) {
1634 m_pFormNotify = pNotify; 1634 m_pFormNotify = pNotify;
1635 } 1635 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/include/cpdf_string.h ('k') | fpdfsdk/fpdfppo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698