diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-01-29 10:53:32 +0000 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2024-02-16 16:35:16 +0100 |
commit | db9e998b09e62eabebde12618f858a6162a9938b (patch) | |
tree | 4aeb9a6dd900378ed954287aa418bce7393c418d | |
parent | dcb2e2515bad3028918e0121068fac7b1d6881d3 (diff) |
ofz: Use-of-uninitialized-value
keep a high water mark of the highest initialized level
Change-Id: Ib799331c523209c4f165dc4c40317e25b6b0cc7c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162625
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
(cherry picked from commit f4b406fc87878130819b9dc57099235eb7c9a628)
-rw-r--r-- | sc/source/core/tool/compiler.cxx | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 84a0d64e155b..125c1acd8e9d 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -4521,6 +4521,7 @@ std::unique_ptr<ScTokenArray> ScCompiler::CompileString( const OUString& rFormul pFunctionStack[0].eOp = ocNone; pFunctionStack[0].nSep = 0; size_t nFunction = 0; + size_t nHighWatermark = 0; short nBrackets = 0; bool bInArray = false; eLastOp = ocOpen; @@ -4540,6 +4541,7 @@ std::unique_ptr<ScTokenArray> ScCompiler::CompileString( const OUString& rFormul ++nFunction; pFunctionStack[ nFunction ].eOp = eLastOp; pFunctionStack[ nFunction ].nSep = 0; + nHighWatermark = nFunction; } } break; @@ -4578,6 +4580,7 @@ std::unique_ptr<ScTokenArray> ScCompiler::CompileString( const OUString& rFormul ++nFunction; pFunctionStack[ nFunction ].eOp = eOp; pFunctionStack[ nFunction ].nSep = 0; + nHighWatermark = nFunction; } } break; @@ -4608,6 +4611,7 @@ std::unique_ptr<ScTokenArray> ScCompiler::CompileString( const OUString& rFormul ++nFunction; pFunctionStack[ nFunction ].eOp = eOp; pFunctionStack[ nFunction ].nSep = 0; + nHighWatermark = nFunction; } } break; @@ -4650,9 +4654,9 @@ std::unique_ptr<ScTokenArray> ScCompiler::CompileString( const OUString& rFormul // Append a parameter for WEEKNUM, all 1.0 // Function is already closed, parameter count is nSep+1 size_t nFunc = nFunction + 1; - if (eOp == ocClose && - (pFunctionStack[ nFunc ].eOp == ocWeek && // 2nd week start - pFunctionStack[ nFunc ].nSep == 0)) + if (eOp == ocClose && nFunc <= nHighWatermark && + pFunctionStack[ nFunc ].nSep == 0 && + pFunctionStack[ nFunc ].eOp == ocWeek) // 2nd week start { if ( !static_cast<ScTokenArray*>(pArr)->Add( new FormulaToken( svSep, ocSep)) || !static_cast<ScTokenArray*>(pArr)->Add( new FormulaDoubleToken( 1.0))) |