summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_structtree.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-27 19:08:26 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-27 19:08:26 +0000
commit81ad373a24575985413c142820be8bf945cad71f (patch)
tree54d5bc47d423f5805def8c7e831ae056e1ed0c2a /fpdfsdk/fpdf_structtree.cpp
parent3071871519db375e22950fad02b87aed43963efc (diff)
downloadpdfium-81ad373a24575985413c142820be8bf945cad71f.tar.xz
Convert CPDF_StructElement::CountKids to size_t
This CL changes CountKids to not used CollectionSize and returns size_t directly. Callers updated as needed. Bug: pdfium:774 Change-Id: I8862218e62cd13be9473fa8116afd29cd3afde04 Reviewed-on: https://pdfium-review.googlesource.com/19510 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_structtree.cpp')
-rw-r--r--fpdfsdk/fpdf_structtree.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/fpdfsdk/fpdf_structtree.cpp b/fpdfsdk/fpdf_structtree.cpp
index b1fca65015..483d894f6e 100644
--- a/fpdfsdk/fpdf_structtree.cpp
+++ b/fpdfsdk/fpdf_structtree.cpp
@@ -99,15 +99,19 @@ FPDF_StructElement_GetTitle(FPDF_STRUCTELEMENT struct_element,
FPDF_EXPORT int FPDF_CALLCONV
FPDF_StructElement_CountChildren(FPDF_STRUCTELEMENT struct_element) {
CPDF_StructElement* elem = ToStructTreeElement(struct_element);
- return elem ? elem->CountKids() : -1;
+ if (!elem)
+ return -1;
+
+ pdfium::base::CheckedNumeric<int> tmp_size = elem->CountKids();
+ return tmp_size.ValueOrDefault(-1);
}
FPDF_EXPORT FPDF_STRUCTELEMENT FPDF_CALLCONV
FPDF_StructElement_GetChildAtIndex(FPDF_STRUCTELEMENT struct_element,
int index) {
CPDF_StructElement* elem = ToStructTreeElement(struct_element);
- if (!elem || index < 0 || index >= elem->CountKids())
+ if (!elem || index < 0 || static_cast<size_t>(index) >= elem->CountKids())
return nullptr;
- return elem->GetKidIfElement(index);
+ return elem->GetKidIfElement(static_cast<size_t>(index));
}