diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-12-17 10:07:10 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-12-17 10:21:38 +0100 |
commit | 4d2be4e7fa811db504a0fade72514b514ac84c96 (patch) | |
tree | 85d68893384f6cb0230a793d1864c4443670abed | |
parent | 4a66c737a137ec6a4c4578901edb6db8a724f4bb (diff) |
fdo#61638 SmParser::NextToken: don't crash on ending dot
Change-Id: Ia9c168e52a99286910c9e63e0e052671c5259ba8
(cherry picked from commit cdd59ee13b1dca7e3d269bf1a3c555903eee96ee)
-rw-r--r-- | starmath/source/parse.cxx | 38 | ||||
-rw-r--r-- | sw/CppunitTest_sw_filters_test.mk | 1 | ||||
-rw-r--r-- | sw/qa/core/data/rtf/pass/fdo61638.rtf | 31 |
3 files changed, 54 insertions, 16 deletions
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx index 5a79bbb7cd11..98b579a5f88f 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 '/': diff --git a/sw/CppunitTest_sw_filters_test.mk b/sw/CppunitTest_sw_filters_test.mk index 0cc65fd00b49..1e96a5cde372 100644 --- a/sw/CppunitTest_sw_filters_test.mk +++ b/sw/CppunitTest_sw_filters_test.mk @@ -70,6 +70,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_filters_test,\ sax/source/expatwrap/expwrap \ sax/source/fastparser/fastsax \ sfx2/util/sfx \ + starmath/util/sm \ svtools/util/svt \ sw/util/msword \ sw/util/sw \ diff --git a/sw/qa/core/data/rtf/pass/fdo61638.rtf b/sw/qa/core/data/rtf/pass/fdo61638.rtf new file mode 100644 index 000000000000..e85245b5e189 --- /dev/null +++ b/sw/qa/core/data/rtf/pass/fdo61638.rtf @@ -0,0 +1,31 @@ +{\rtf1 +{\mmath +{\*\moMathPara +{\*\moMath +{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\f34\insrsid7877010 \hich\af34\dbch\af31505\loch\f34 +{\mr\mscr0\msty2 a} +} +{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\f34\insrsid7877010 \hich\af34\dbch\af31505\loch\f34 +{\mr\mscr0\msty2 =} +} +{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\f34\insrsid7877010 \hich\af34\dbch\af31505\loch\f34 +{\mr\mscr0\msty2 b} +} +{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\f34\insrsid7877010 \hich\af34\dbch\af31505\loch\f34 +{\mr\mscr0\msty2 +} +} +{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\f34\insrsid7877010 \hich\af34\dbch\af31505\loch\f34 +{\mr\mscr0\msty2 c} +} +{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\f34\insrsid7877010 \hich\af34\dbch\af31505\loch\f34 +{\mr\mscr0\msty2 +} +} +{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\f34\insrsid7877010 \hich\af34\dbch\af31505\loch\f34 +{\mr\mscr0\msty2 d} +} +{\rtlch\fcs1 \af31507 \ltrch\fcs0 \i\f34\insrsid7877010 .} +} +} +} +{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid7877010 \par } +} |