summaryrefslogtreecommitdiff
path: root/formula
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2020-05-12 23:49:46 +0200
committerMichael Stahl <michael.stahl@cib.de>2020-05-13 10:11:13 +0200
commitcf842260e9e0dceb4d7b3d5f7125b9730fe263d9 (patch)
treec70382cb38a9fbe0ac289e4218e9eb4b10cb5ca5 /formula
parentbfaa243b0cac1753330982bedb47f272724bfa1c (diff)
Check maximum end position to not assert() or "!!br0ken!!"
While editing a formula in the Function Wizard it could happen that inserting an unclosed quote attempted to copy one more character than string length for parameter display. For example =FUNC("A";") Change-Id: Ic25ee0b97c3baee8d2e964c9e4b907415b0d889e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94086 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins (cherry picked from commit f9790da286f2d2fa47f1748f8cfa6172c6622ca3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93997 Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Diffstat (limited to 'formula')
-rw-r--r--formula/source/ui/dlg/FormulaHelper.cxx4
1 files changed, 3 insertions, 1 deletions
diff --git a/formula/source/ui/dlg/FormulaHelper.cxx b/formula/source/ui/dlg/FormulaHelper.cxx
index b3c0b4a204bc..09bfe09ed67d 100644
--- a/formula/source/ui/dlg/FormulaHelper.cxx
+++ b/formula/source/ui/dlg/FormulaHelper.cxx
@@ -346,7 +346,9 @@ sal_Int32 FormulaHelper::GetFunctionEnd( const OUString& rStr, sal_Int32 nStart
nStart++; // Set behind found position
}
- return nStart;
+ // nStart > nStrLen can happen if there was an unclosed quote; instead of
+ // checking that in every loop iteration check it once here.
+ return std::min(nStart, nStrLen);
}