diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-10-17 17:57:51 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-10-17 17:57:51 +0000 |
commit | 5ae6c564d16ce8b625df3d1950abc822f9ecc987 (patch) | |
tree | 96bb64df3166e46db397e405789588bf8dc53842 /fpdfsdk/fpdf_annot.cpp | |
parent | 785a26dc649af80c593f899a606dff4dae7c48fd (diff) | |
download | pdfium-5ae6c564d16ce8b625df3d1950abc822f9ecc987.tar.xz |
Add CPDF_{Array,Dictionary}Locker to catch illegal iteration patterns.
Move begin/end methods onto locker object which tracks whether
iterators are in existence.
Change-Id: Ia869f313fce48d10a0d0180d0cc083eed6ea1584
Reviewed-on: https://pdfium-review.googlesource.com/c/44070
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_annot.cpp')
-rw-r--r-- | fpdfsdk/fpdf_annot.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp index e4bfab0b70..2c8e68eca7 100644 --- a/fpdfsdk/fpdf_annot.cpp +++ b/fpdfsdk/fpdf_annot.cpp @@ -277,17 +277,18 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFPage_GetAnnotIndex(FPDF_PAGE page, if (!pAnnots) return -1; + CPDF_ArrayLocker locker(pAnnots); CPDF_Dictionary* pDict = pAnnot->GetAnnotDict(); auto it = - std::find_if(pAnnots->begin(), pAnnots->end(), + std::find_if(locker.begin(), locker.end(), [pDict](const std::unique_ptr<CPDF_Object>& candidate) { return candidate->GetDirect() == pDict; }); - if (it == pAnnots->end()) + if (it == locker.end()) return -1; - return it - pAnnots->begin(); + return it - locker.begin(); } FPDF_EXPORT void FPDF_CALLCONV FPDFPage_CloseAnnot(FPDF_ANNOTATION annot) { |