From 9a93484a61fe0e9b8a4a4c664f596857eb78f819 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Wed, 8 Nov 2017 16:02:00 +0000 Subject: Make sure that iterator stays in bounds during IsHypen BUG=chromium:782596,chromium:781804 Change-Id: I020be3cf813221bb8314f045d83014a25cb9a950 Reviewed-on: https://pdfium-review.googlesource.com/18070 Reviewed-by: dsinclair Commit-Queue: dsinclair --- core/fpdftext/cpdf_textpage.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp index 6ccadff701..485fba24a8 100644 --- a/core/fpdftext/cpdf_textpage.cpp +++ b/core/fpdftext/cpdf_textpage.cpp @@ -1226,20 +1226,17 @@ bool CPDF_TextPage::IsHyphen(wchar_t curChar) const { return false; auto iter = curText.rbegin(); - for (; iter != curText.rend() && *iter == 0x20; iter++) { + for (; (iter + 1) != curText.rend() && *iter == 0x20; iter++) { // Do nothing } - if (iter != curText.rend()) { - if (!IsHyphenCode(*iter)) - return false; + if (!IsHyphenCode(*iter)) + return false; + + if ((iter + 1) != curText.rend()) { iter++; if (FXSYS_iswalpha(*iter) && FXSYS_iswalpha(*iter)) return true; - } else { - iter--; - if (!IsHyphenCode(*iter)) - return false; } const PAGECHAR_INFO* preInfo; -- cgit v1.2.3