From 81ad373a24575985413c142820be8bf945cad71f Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 27 Nov 2017 19:08:26 +0000 Subject: 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 Commit-Queue: dsinclair --- fpdfsdk/fpdf_structtree.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'fpdfsdk') 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 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(index) >= elem->CountKids()) return nullptr; - return elem->GetKidIfElement(index); + return elem->GetKidIfElement(static_cast(index)); } -- cgit v1.2.3