Properly handle \n, \r, \r\n when inserting text
BUG=pdfium:877
Change-Id: I6aa3e53057c27700c2d3c0c1692fa86ae9b3a03c
Reviewed-on: https://pdfium-review.googlesource.com/12711
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
diff --git a/fpdfsdk/pwl/cpwl_edit_impl.cpp b/fpdfsdk/pwl/cpwl_edit_impl.cpp
index 42eaa16..c44301f 100644
--- a/fpdfsdk/pwl/cpwl_edit_impl.cpp
+++ b/fpdfsdk/pwl/cpwl_edit_impl.cpp
@@ -1846,13 +1846,11 @@
switch (word) {
case 0x0D:
wp = m_pVT->InsertSection(wp, nullptr, nullptr);
- if (sText[i + 1] == 0x0A)
+ if (i + 1 < sz && sText[i + 1] == 0x0A)
i++;
break;
case 0x0A:
wp = m_pVT->InsertSection(wp, nullptr, nullptr);
- if (sText[i + 1] == 0x0D)
- i++;
break;
case 0x09:
word = 0x20;