sc/source/core/tool/interpr8.cxx | 42 +++++++++++++++++++++++++-------------- sc/source/ui/src/scfuncs.src | 8 +++---- 2 files changed, 31 insertions(+), 19 deletions(-)
New commits: commit 98ac8e769cee49852e1bfee5fc5a38ab20959eba Author: Eike Rathke <er...@redhat.com> Date: Tue Apr 26 18:02:15 2016 +0200 check availability of stack and some nitpicks, tdf#97831 follow-up See comments on https://gerrit.libreoffice.org/#/c/23601/5 Change-Id: Ib8d5a6cbf87f8b6cafd825f380c7e65c3227aefd diff --git a/sc/source/core/tool/interpr8.cxx b/sc/source/core/tool/interpr8.cxx index 722b164..20ceb72 100644 --- a/sc/source/core/tool/interpr8.cxx +++ b/sc/source/core/tool/interpr8.cxx @@ -1397,10 +1397,12 @@ void ScInterpreter::ScConcat_MS() //reverse order of parameter stack to simplify concatenation: FormulaToken* p; - for ( short i = 0; i < short( nParamCount / 2 ); i++ ) + assert( sp >= nParamCount && " less stack elements than parameters"); + short nStackParams = std::min<short>( sp, nParamCount); + for ( short i = 0; i < short( nStackParams / 2 ); i++ ) { - p = pStack[ sp - ( nParamCount - i ) ]; - pStack[ sp - ( nParamCount - i ) ] = pStack[ sp - 1 - i ]; + p = pStack[ sp - ( nStackParams - i ) ]; + pStack[ sp - ( nStackParams - i ) ] = pStack[ sp - 1 - i ]; pStack[ sp - 1 - i ] = p; } @@ -1430,8 +1432,8 @@ void ScInterpreter::ScConcat_MS() aResBuf.append( OUString::number( aCell.getValue() ) ); } } - break; } + break; case svDoubleRef : case svRefList : { @@ -1474,8 +1476,8 @@ void ScInterpreter::ScConcat_MS() } } } - break; } + break; case svMatrix : case svExternalSingleRef: case svExternalDoubleRef: @@ -1505,8 +1507,11 @@ void ScInterpreter::ScConcat_MS() } } } + break; default: - break; + PopError(); + SetError( errIllegalArgument); + break; } } PushString( aResBuf.makeStringAndClear() ); @@ -1520,10 +1525,12 @@ void ScInterpreter::ScTextJoin_MS() { //reverse order of parameter stack to simplify processing FormulaToken* p; - for ( short i = 0; i < short( nParamCount / 2 ); i++ ) + assert( sp >= nParamCount && " less stack elements than parameters"); + short nStackParams = std::min<short>( sp, nParamCount); + for ( short i = 0; i < short( nStackParams / 2 ); i++ ) { - p = pStack[ sp - ( nParamCount - i ) ]; - pStack[ sp - ( nParamCount - i ) ] = pStack[ sp - 1 - i ]; + p = pStack[ sp - ( nStackParams - i ) ]; + pStack[ sp - ( nStackParams - i ) ] = pStack[ sp - 1 - i ]; pStack[ sp - 1 - i ] = p; } @@ -1553,8 +1560,8 @@ void ScInterpreter::ScTextJoin_MS() xDelimiter.push_back( OUString::number( aCell.getValue() ) ); } } - break; } + break; case svDoubleRef : case svRefList : { @@ -1599,8 +1606,8 @@ void ScInterpreter::ScTextJoin_MS() xDelimiter.push_back( "" ); } } - break; } + break; case svMatrix : case svExternalSingleRef: case svExternalDoubleRef: @@ -1635,7 +1642,10 @@ void ScInterpreter::ScTextJoin_MS() } } } + break; default: + PopError(); + SetError( errIllegalArgument); break; } if ( xDelimiter.empty() ) @@ -1675,8 +1685,8 @@ void ScInterpreter::ScTextJoin_MS() bFirst = false; aResBuf.append( aStr ); } - break; } + break; case svSingleRef : { ScAddress aAdr; @@ -1712,8 +1722,8 @@ void ScInterpreter::ScTextJoin_MS() bFirst = false; aResBuf.append( aStr ); } - break; } + break; case svDoubleRef : case svRefList : { @@ -1774,8 +1784,8 @@ void ScInterpreter::ScTextJoin_MS() } } } - break; } + break; case svMatrix : case svExternalSingleRef: case svExternalDoubleRef: @@ -1842,9 +1852,11 @@ void ScInterpreter::ScTextJoin_MS() else bFirst = false; } - break; } + break; default: + PopError(); + SetError( errIllegalArgument); break; } } diff --git a/sc/source/ui/src/scfuncs.src b/sc/source/ui/src/scfuncs.src index f611834..ae82ad4e 100644 --- a/sc/source/ui/src/scfuncs.src +++ b/sc/source/ui/src/scfuncs.src @@ -11520,7 +11520,7 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2 }; String 2 // Name of Parameter 1 { - Text [ en-US ] = "text " ; + Text [ en-US ] = "text" ; }; String 3 // Description of Parameter 1 { @@ -11544,7 +11544,7 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2 }; String 2 // Name of Parameter 1 to last { - Text [ en-US ] = "text " ; + Text [ en-US ] = "text" ; }; String 3 // Description of Parameter 1 to last { @@ -11568,7 +11568,7 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2 }; String 2 // Name of Parameter 1 { - Text [ en-US ] = "delimiter " ; + Text [ en-US ] = "delimiter" ; }; String 3 // Description of Parameter 1 { @@ -11584,7 +11584,7 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2 }; String 6 // Name of Parameter 3 to last { - Text [ en-US ] = "text " ; + Text [ en-US ] = "text" ; }; String 7 // Description of Parameter 3 to last { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits