summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-10-07 20:12:17 +0100
committerMiklos Vajna <vmiklos@collabora.com>2024-10-08 08:49:02 +0200
commit5c17afa35804814973b7612df350f3df1ebc9eaf (patch)
tree2b43e97a55f8e40e6f8f4adabd533a8a90fe26a9 /sc
parent541272d3eaa322ccdd1b926add031a39faeccf49 (diff)
Resolves: tdf#163275 crash in async dialog use after free
since: commit b39c6082aa975ed8e5696c3dc24c3025ed07bbb6 CommitDate: Wed Jan 31 10:33:48 2024 +0100 Implement Async AutoCorrectQuery Dialogs for Formula Check in calc Change-Id: Ie184f72cfa858ed1fc6d9eb5205dea985767eec5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174646 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/view/viewfunc.cxx11
1 files changed, 6 insertions, 5 deletions
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index db2bb7c8e717..20f3795400b9 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -144,7 +144,7 @@ struct FormulaProcessingContext
std::shared_ptr<ScTokenArray> pArr;
std::shared_ptr<ScTokenArray> pArrFirst;
- const EditTextObject* pData;
+ std::shared_ptr<EditTextObject> xTextObject;
ScMarkData aMark;
ScViewFunc& rViewFunc;
@@ -559,10 +559,10 @@ namespace
if (nType == SvNumFormatType::TEXT ||
((context->aString[0] == '+' || context->aString[0] == '-') && nError != FormulaError::NONE && context->aString == context->aFormula))
{
- if ( context->pData )
+ if ( context->xTextObject )
{
- // A clone of context->pData will be stored in the cell.
- context->GetDocFunc().SetEditCell(*(context->aPos), *context->pData, true);
+ // A clone of context->xTextObject will be stored in the cell.
+ context->GetDocFunc().SetEditCell(*(context->aPos), *context->xTextObject, true);
}
else
context->GetDocFunc().SetStringCell(*(context->aPos), context->aFormula, true);
@@ -726,6 +726,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
i = rMark.GetFirstSelected();
auto aPosPtr = std::make_shared<ScAddress>(nCol, nRow, i);
auto aCompPtr = std::make_shared<ScCompiler>(rDoc, *aPosPtr, rDoc.GetGrammar(), true, false);
+ std::unique_ptr<EditTextObject> xTextObject(pData ? pData->Clone() : nullptr);
//2do: enable/disable autoCorrection via calcoptions
aCompPtr->SetAutoCorrection( true );
@@ -738,7 +739,7 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
std::shared_ptr< ScTokenArray > pArr;
FormulaProcessingContext context_instance{
- aPosPtr, aCompPtr, xModificator, pArr, nullptr, pData,
+ aPosPtr, aCompPtr, xModificator, pArr, nullptr, std::move(xTextObject),
rMark, *this, OUString(), aFormula, rString, nCol,
nRow, nTab, bMatrixExpand, bNumFmtChanged, bRecord
};