From c2df008640f56631735dd3ae89e118c9c56cd36d Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 12 Mar 2018 14:17:54 +0000 Subject: Handle inserting negative values without a selection When handling the AFNumber_Keystroke callback, if the changed value is negative and there is no selection, we'd incorrectly error out thinking we were inserting before the negative sign. This CL checks if the selection string is empty before erroring out. Bug: chromium:817433 Change-Id: I0ca08e121e9a8c207e9c7793f5b8a4e795c135e6 Reviewed-on: https://pdfium-review.googlesource.com/28110 Commit-Queue: dsinclair Reviewed-by: Lei Zhang Reviewed-by: Henrique Nakashima --- fxjs/cjs_publicmethods.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'fxjs/cjs_publicmethods.cpp') diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp index d613f4888a..28df0a305b 100644 --- a/fxjs/cjs_publicmethods.cpp +++ b/fxjs/cjs_publicmethods.cpp @@ -1009,8 +1009,8 @@ CJS_Return CJS_PublicMethods::AFNumber_Keystroke( bool bHasSign = wstrValue.Contains(L'-') && !wstrSelected.Contains(L'-'); if (bHasSign) { - // can't insert "change" in front to sign postion. - if (pEvent->SelStart() == 0) { + // can't insert "change" in front of sign position. + if (!wstrSelected.IsEmpty() && pEvent->SelStart() == 0) { pEvent->Rc() = false; return CJS_Return(true); } -- cgit v1.2.3