summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2013-12-17 10:07:10 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-12-17 10:10:44 +0100
commitcdd59ee13b1dca7e3d269bf1a3c555903eee96ee (patch)
treef5befbf3d3df6b24b0e32e41265c97d68d6798ca /starmath
parentc302a773d4cabca7f7bc5871be6c2003b05fafa3 (diff)
fdo#61638 SmParser::NextToken: don't crash on ending dot
Change-Id: Ia9c168e52a99286910c9e63e0e052671c5259ba8
Diffstat (limited to 'starmath')
-rw-r--r--starmath/source/parse.cxx38
1 files changed, 22 insertions, 16 deletions
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index 9b8fc8da2f72..635cf3880213 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -872,24 +872,30 @@ void SmParser::NextToken()
break;
case '.':
{
- // for compatibility with SO5.2
- // texts like .34 ...56 ... h ...78..90
- // will be treated as numbers
- m_aCurToken.eType = TNUMBER;
- m_aCurToken.cMathChar = '\0';
- m_aCurToken.nGroup = 0;
- m_aCurToken.nLevel = 5;
-
- sal_Int32 nTxtStart = m_nBufferIndex;
- sal_Unicode cChar;
- do
+ // Only one character? Then it can't be a number.
+ if (m_nBufferIndex < m_aBufferString.getLength() - 1)
{
- cChar = m_aBufferString[ ++m_nBufferIndex ];
+ // for compatibility with SO5.2
+ // texts like .34 ...56 ... h ...78..90
+ // will be treated as numbers
+ m_aCurToken.eType = TNUMBER;
+ m_aCurToken.cMathChar = '\0';
+ m_aCurToken.nGroup = 0;
+ m_aCurToken.nLevel = 5;
+
+ sal_Int32 nTxtStart = m_nBufferIndex;
+ sal_Unicode cChar;
+ do
+ {
+ cChar = m_aBufferString[ ++m_nBufferIndex ];
+ }
+ while ( cChar == '.' || rtl::isAsciiDigit( cChar ) );
+
+ m_aCurToken.aText = m_aBufferString.copy( nTxtStart, m_nBufferIndex - nTxtStart );
+ aRes.EndPos = m_nBufferIndex;
}
- while ( cChar == '.' || rtl::isAsciiDigit( cChar ) );
-
- m_aCurToken.aText = m_aBufferString.copy( nTxtStart, m_nBufferIndex - nTxtStart );
- aRes.EndPos = m_nBufferIndex;
+ else
+ bHandled = false;
}
break;
case '/':