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

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

Issue 2376193002: Fix leaks in CFieldTree::Node. (Closed)
Patch Set: Created 4 years, 2 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 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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 421
422 const CFX_WideString& GetShortName() const { return m_ShortName; } 422 const CFX_WideString& GetShortName() const { return m_ShortName; }
423 423
424 private: 424 private:
425 CPDF_FormField* GetFieldInternal(size_t* pFieldsToGo) { 425 CPDF_FormField* GetFieldInternal(size_t* pFieldsToGo) {
426 if (m_pField) { 426 if (m_pField) {
427 if (*pFieldsToGo == 0) 427 if (*pFieldsToGo == 0)
428 return m_pField; 428 return m_pField;
429 429
430 --*pFieldsToGo; 430 --*pFieldsToGo;
431 return nullptr;
432 } 431 }
433 for (size_t i = 0; i < GetChildrenCount(); ++i) { 432 for (size_t i = 0; i < GetChildrenCount(); ++i) {
434 CPDF_FormField* pField = GetChildAt(i)->GetFieldInternal(pFieldsToGo); 433 CPDF_FormField* pField = GetChildAt(i)->GetFieldInternal(pFieldsToGo);
435 if (pField) 434 if (pField)
436 return pField; 435 return pField;
437 } 436 }
438 return nullptr; 437 return nullptr;
439 } 438 }
440 439
441 size_t CountFieldsInternal(int nLevel) const { 440 size_t CountFieldsInternal(int nLevel) const {
442 if (nLevel > nMaxRecursion) 441 if (nLevel > nMaxRecursion)
443 return 0; 442 return 0;
444 if (m_pField)
445 return 1;
446 443
447 size_t count = 0; 444 size_t count = 0;
445 if (m_pField)
446 ++count;
447
448 for (size_t i = 0; i < GetChildrenCount(); ++i) 448 for (size_t i = 0; i < GetChildrenCount(); ++i)
449 count += GetChildAt(i)->CountFieldsInternal(nLevel + 1); 449 count += GetChildAt(i)->CountFieldsInternal(nLevel + 1);
450 return count; 450 return count;
451 } 451 }
452 452
453 std::vector<Node*> m_Children; 453 std::vector<Node*> m_Children;
454 CFX_WideString m_ShortName; 454 CFX_WideString m_ShortName;
455 CPDF_FormField* m_pField; 455 CPDF_FormField* m_pField;
456 }; 456 };
457 457
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 else if (iType == FIELDTYPE_LISTBOX) 1311 else if (iType == FIELDTYPE_LISTBOX)
1312 m_pFormNotify->AfterSelectionChange(pField); 1312 m_pFormNotify->AfterSelectionChange(pField);
1313 else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD) 1313 else if (iType == FIELDTYPE_COMBOBOX || iType == FIELDTYPE_TEXTFIELD)
1314 m_pFormNotify->AfterValueChange(pField); 1314 m_pFormNotify->AfterValueChange(pField);
1315 } 1315 }
1316 } 1316 }
1317 1317
1318 void CPDF_InterForm::SetFormNotify(IPDF_FormNotify* pNotify) { 1318 void CPDF_InterForm::SetFormNotify(IPDF_FormNotify* pNotify) {
1319 m_pFormNotify = pNotify; 1319 m_pFormNotify = pNotify;
1320 } 1320 }
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