summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_structtree.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-27 19:34:46 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-27 19:34:46 +0000
commite6ccf2578ae04c796a69f3596e4b4730a45da378 (patch)
tree72fdfbed0d5f4e1c1b8af03869cc10714bb97703 /fpdfsdk/fpdf_structtree.cpp
parent3fc7fe5e4d8fa257e35e6ae86fc6cf4d6b5016a2 (diff)
downloadpdfium-e6ccf2578ae04c796a69f3596e4b4730a45da378.tar.xz
Convert CPDF_StructTree to size_t
This CL removes the use of CollectionSize from CPDF_StructTree and uses size_t in the callers. Bug: pdfium:774 Change-Id: I860a51a533642c949c497ca26e74ba064a8aa9ba Reviewed-on: https://pdfium-review.googlesource.com/19530 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_structtree.cpp')
-rw-r--r--fpdfsdk/fpdf_structtree.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/fpdfsdk/fpdf_structtree.cpp b/fpdfsdk/fpdf_structtree.cpp
index 483d894f6e..30b7c3fce7 100644
--- a/fpdfsdk/fpdf_structtree.cpp
+++ b/fpdfsdk/fpdf_structtree.cpp
@@ -55,15 +55,21 @@ FPDF_StructTree_Close(FPDF_STRUCTTREE struct_tree) {
FPDF_EXPORT int FPDF_CALLCONV
FPDF_StructTree_CountChildren(FPDF_STRUCTTREE struct_tree) {
CPDF_StructTree* tree = ToStructTree(struct_tree);
- return tree ? tree->CountTopElements() : -1;
+ if (!tree)
+ return -1;
+
+ pdfium::base::CheckedNumeric<int> tmp_size = tree->CountTopElements();
+ return tmp_size.ValueOrDefault(-1);
}
FPDF_EXPORT FPDF_STRUCTELEMENT FPDF_CALLCONV
FPDF_StructTree_GetChildAtIndex(FPDF_STRUCTTREE struct_tree, int index) {
CPDF_StructTree* tree = ToStructTree(struct_tree);
- if (!tree || index < 0 || index >= tree->CountTopElements())
+ if (!tree || index < 0 ||
+ static_cast<size_t>(index) >= tree->CountTopElements()) {
return nullptr;
- return tree->GetTopElement(index);
+ }
+ return tree->GetTopElement(static_cast<size_t>(index));
}
FPDF_EXPORT unsigned long FPDF_CALLCONV