Fix FindPageIndex() search algorithm.
Regression introduced in 5b4135d22ddd1450327931ee04fb3f14ada95471.
Required when reaching a leaf node of the Pages tree during recursion of
FindPageIndex().
A check for 0 |skip_count| is required before decrementing. |skip_count|
is unsigned so whenever this is decremented, the check against the
"Count" key of the "Pages" dictionary always succeeds and |skip_count|
is incorrectly reduced again.
Bug: pdfium:1506
Change-Id: If82b77ab6e1ba2ad44b8d138a7ebffecb079313a
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/68390
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp
index 1505834..05b5f47 100644
--- a/core/fpdfapi/parser/cpdf_document.cpp
+++ b/core/fpdfapi/parser/cpdf_document.cpp
@@ -59,7 +59,9 @@
if (objnum == pNode->GetObjNum())
return *index;
- (*skip_count)--;
+ if (*skip_count != 0)
+ (*skip_count)--;
+
(*index)++;
return -1;
}