Fix leaks in CFieldTree::Node.
Correctly account for non-leaf Nodes that have CPDF_FormField pointers.
Review-Url: https://codereview.chromium.org/2376193002
diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp
index 29063f5..af72bd2 100644
--- a/core/fpdfdoc/cpdf_interform.cpp
+++ b/core/fpdfdoc/cpdf_interform.cpp
@@ -428,7 +428,6 @@
return m_pField;
--*pFieldsToGo;
- return nullptr;
}
for (size_t i = 0; i < GetChildrenCount(); ++i) {
CPDF_FormField* pField = GetChildAt(i)->GetFieldInternal(pFieldsToGo);
@@ -441,10 +440,11 @@
size_t CountFieldsInternal(int nLevel) const {
if (nLevel > nMaxRecursion)
return 0;
- if (m_pField)
- return 1;
size_t count = 0;
+ if (m_pField)
+ ++count;
+
for (size_t i = 0; i < GetChildrenCount(); ++i)
count += GetChildAt(i)->CountFieldsInternal(nLevel + 1);
return count;