diff options
author | Caolán McNamara <caolanm@redhat.com> | 2013-10-24 13:51:09 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-10-24 13:51:09 +0100 |
commit | 082e1fa44cf6b3d61d571bab99407d3f38d8288d (patch) | |
tree | 4d6a020f498585ff67b5ecdcc0ad10566830a586 | |
parent | 8755bef6dd4145f2eac8c18a4a7eb58c52b83d47 (diff) |
more string bounds checks for sc
Change-Id: I99293a91018c130415bd3816fa23f44643512a74
-rw-r--r-- | sc/source/core/tool/compiler.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 14 | ||||
-rw-r--r-- | sc/source/ui/view/viewdata.cxx | 2 |
3 files changed, 12 insertions, 8 deletions
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 33ba8899501b..5a7d8e277348 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -3673,14 +3673,14 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula ) aCorrectedSymbol = ""; } sal_uInt8 nForced = 0; // ==formula forces recalc even if cell is not visible - if( aFormula[nSrcPos] == '=' ) + if( nSrcPos < aFormula.getLength() && aFormula[nSrcPos] == '=' ) { nSrcPos++; nForced++; if ( bAutoCorrect ) aCorrectedFormula += "="; } - if( aFormula[nSrcPos] == '=' ) + if( nSrcPos < aFormula.getLength() && aFormula[nSrcPos] == '=' ) { nSrcPos++; nForced++; diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 87713ec1c98c..de88da363122 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -2247,11 +2247,15 @@ void ScInputHandler::UpdateFormulaMode() { SfxApplication* pSfxApp = SFX_APP(); - if ( pEngine->GetParagraphCount() == 1 && - ( pEngine->GetText(0)[0] == '=' || - pEngine->GetText(0)[0] == '+' || - pEngine->GetText(0)[0] == '-' ) && - !bProtected ) + bool bIsFormula = !bProtected && pEngine->GetParagraphCount() == 1; + if (bIsFormula) + { + const OUString& rText = pEngine->GetText(0); + bIsFormula = !rText.isEmpty() && + (rText[0] == '=' || rText[0] == '+' || rText[0] == '-'); + } + + if ( bIsFormula ) { if (!bFormulaMode) { diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 0769315c8c56..1434cd49f508 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -1328,7 +1328,7 @@ void ScViewData::EditGrowY( sal_Bool bInitial ) // Subsequent calls with empty text might involve changed attributes (including // font height), so they are treated like normal text. OUString aText = pEngine->GetText( 0 ); - if ( ( aText.isEmpty() && bInitial ) || aText[0] == '=' ) + if ( ( aText.isEmpty() && bInitial ) || (!aText.isEmpty() && aText[0] == '=') ) nAllowedExtra = SC_GROWY_BIG_EXTRA; } |