From e11fe1886a58498899d7b074348186a46c5f6ac6 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 25 Jan 2015 21:20:32 +0000 Subject: coverity#1266474 Dereference null return value Change-Id: I240be73629a26a7067bfde5d2b662315a3259d1f --- sc/source/core/data/documen4.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'sc') diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index 27f8a20d9267..ba09b3b92508 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -82,14 +82,19 @@ bool ScDocument::Solver(SCCOL nFCol, SCROW nFRow, SCTAB nFTab, GetCellType(nVCol, nVRow, nVTab, eVType); // #i108005# convert target value to number using default format, // as previously done in ScInterpreter::GetDouble + ScFormulaCell* pFormula = NULL; double fTargetVal = 0.0; sal_uInt32 nFIndex = 0; if ( eFType == CELLTYPE_FORMULA && eVType == CELLTYPE_VALUE && GetFormatTable()->IsNumberFormat( sValStr, nFIndex, fTargetVal ) ) + { + ScAddress aFormulaAdr( nFCol, nFRow, nFTab ); + pFormula = GetFormulaCell( aFormulaAdr ); + } + if (pFormula) { bool bDoneIteration = false; ScAddress aValueAdr( nVCol, nVRow, nVTab ); - ScAddress aFormulaAdr( nFCol, nFRow, nFTab ); double* pVCell = GetValueCell( aValueAdr ); ScRange aVRange( aValueAdr, aValueAdr ); // for SetDirty @@ -104,7 +109,6 @@ bool ScDocument::Solver(SCCOL nFCol, SCROW nFRow, SCTAB nFTab, double fBestF, fFPrev; fBestX = fXPrev = fSaveVal; - ScFormulaCell* pFormula = GetFormulaCell( aFormulaAdr ); pFormula->Interpret(); bool bError = ( pFormula->GetErrCode() != 0 ); // bError always corresponds with fF -- cgit