This change fixes an issue in CPDFXFA_Context::DeletePage.
If a page gets deleted, the index of the following page changes and
this has to be updated.
Change-Id: I923ba181e12bebc2791d37bfaa5ade06bde7db66
Bug: pdfium:2035
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/111790
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/AUTHORS b/AUTHORS
index 1aa27d3..d3c30ba 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -33,6 +33,7 @@
Ralf Sippl <ralf.sippl@gmail.com>
Robert Collyer <rcollyer99@gmail.com>
Ryan Wiley <wileyrr@gmail.com>
+Stefan Ziegler <sz5000@gmx.de>
Stephan Hartmann <stha09@googlemail.com>
Tibor Dusnoki <tdusnoki@inf.u-szeged.hu>
Wang Qing <wangqing-hf@loongson.cn>
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
index 4450f8a..8d48750 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
@@ -262,8 +262,14 @@
// if it's a valid page in the document.
m_pPDFDoc->DeletePage(page_index);
- if (fxcrt::IndexInBounds(m_XFAPageList, page_index))
- m_XFAPageList[page_index].Reset();
+ if (fxcrt::IndexInBounds(m_XFAPageList, page_index)) {
+ m_XFAPageList.erase(m_XFAPageList.begin() + page_index);
+ for (int i = page_index; i < fxcrt::CollectionSize<int>(m_XFAPageList); i++) {
+ if (m_XFAPageList[i]) {
+ m_XFAPageList[i]->SetXFAPageViewIndex(i);
+ }
+ }
+ }
}
bool CPDFXFA_Context::ContainsExtensionForm() const {