summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2024-12-16 23:03:22 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2024-12-17 11:11:58 +0100
commit85b7a25135eb96919d62a108fea18eab5531a4da (patch)
tree04d1ac29da8c46d008448f361f1f92be83e94b61 /sc
parentbc8a86743d122a7df8fcabf59959705895e631f9 (diff)
sc: Dereference after null check
C:/cygwin64/home/tdf/jenkins/workspace/gerrit_windows/sc/source/core/data/column3.cxx(2821): error C2220: the following warning is treated as an error C:\cygwin64\home\tdf\jenkins\workspace\gerrit_windows\sc\source\core\data\column3.cxx(2752) : warning C6011: Dereferencing NULL pointer 'pPattern'. : Lines: 2723, 2726, 2727, 2728, 2730, 2731, 2732, 2733, 2734, 2735, 2736, 2737, 2738, 2739, 2740, 2742, 2744, 2745, 2747, 2751, 2752, 2753, 2754, 2756, 2762, 2763, 2766, 2791, 2809, 2811, 2814, 2819, 2740, 2742, 2744, 2745, 2747, 2751, 2752 make[1]: *** [C:/cygwin64/home/tdf/jenkins/workspace/gerrit_windows/solenv/gbuild/LinkTarget.mk:339: C:/cygwin64/home/tdf/jenkins/workspace/gerrit_windows/workdir/CxxObject/sc/source/core/data/column3.o] Error 2 After commit 2c613da01d02d45a140b94b391a142aede46e8b8 Author: Noel Grandin <noel.grandin@collabora.co.uk> Date: Wed Dec 4 11:20:01 2024 +0200 tdf#163010 inline and cache rDoc.GetCondFormat call Change-Id: If9093d5b43ae63e059b3f0597c85b326599e9ed0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178621 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/column3.cxx62
1 files changed, 30 insertions, 32 deletions
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 7c2cd876f906..8d9a4e9731b2 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2731,7 +2731,6 @@ void ScColumn::GetBackColorFilterEntries(SCROW nRow1, SCROW nRow2, ScFilterEntri
ScRefCellValue aPrevCellValue;
Color aPrevPatternColor;
Color aPrevInsertColor;
- const ScPatternAttr* pPattern = nullptr;
ScConditionalFormat* pCondFormat = nullptr;
const ScCondFormatIndexes* pCondFormats = nullptr;
Color aBackgroundBrushColor;
@@ -2748,42 +2747,41 @@ void ScColumn::GetBackColorFilterEntries(SCROW nRow1, SCROW nRow2, ScFilterEntri
; // then the previous value of pPattern and pCondFormat and pCondFormats and aBackgroundBrushColor is still valid
else
{
- pPattern = pAttrArray->GetPatternRange(nPatternStartRow, nPatternEndRow, nRow1);
- pCondFormats = &pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData();
- sal_uInt32 nIndex = 0;
- if(!pCondFormats->empty())
- nIndex = (*pCondFormats)[0];
- if (nIndex)
+ if (const ScPatternAttr* pPattern = pAttrArray->GetPatternRange(nPatternStartRow, nPatternEndRow, nRow1))
{
- assert(pCondFormList);
- pCondFormat = pCondFormList->GetFormat( nIndex );
- }
- else
- pCondFormat = nullptr;
- aBackgroundBrushColor = pPattern->GetItem(ATTR_BACKGROUND).GetColor();
- }
-
- if (pPattern)
- {
- if (!pCondFormats->empty())
- {
- // Speed up processing when dealing with runs of identical cells. This avoids
- // an expensive GetCondResult call.
- ScRefCellValue aCellValue = GetCellValue(nRow1);
- if (pPrevPattern == pPattern && aCellValue == aPrevCellValue)
+ pCondFormats = &pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData();
+ sal_uInt32 nIndex = 0;
+ if(!pCondFormats->empty())
+ nIndex = (*pCondFormats)[0];
+ if (nIndex)
{
- aBackColor = aPrevPatternColor;
- bCondBackColor = true;
+ assert(pCondFormList);
+ pCondFormat = pCondFormList->GetFormat( nIndex );
}
else
+ pCondFormat = nullptr;
+ aBackgroundBrushColor = pPattern->GetItem(ATTR_BACKGROUND).GetColor();
+
+ if (!pCondFormats->empty())
{
- const SfxItemSet* pCondSet = rDoc.GetCondResult(GetCol(), nRow1, GetTab());
- const SvxBrushItem* pCondBrush = &pPattern->GetItem(ATTR_BACKGROUND, pCondSet);
- aBackColor = pCondBrush->GetColor();
- bCondBackColor = true;
- aPrevCellValue = aCellValue;
- pPrevPattern = pPattern;
- aPrevPatternColor = aBackColor;
+ // Speed up processing when dealing with runs of identical cells. This avoids
+ // an expensive GetCondResult call.
+ ScRefCellValue aCellValue = GetCellValue(nRow1);
+ if (pPrevPattern == pPattern && aCellValue == aPrevCellValue)
+ {
+ aBackColor = aPrevPatternColor;
+ bCondBackColor = true;
+ }
+ else
+ {
+ const SfxItemSet* pCondSet = rDoc.GetCondResult(GetCol(), nRow1, GetTab());
+ const SvxBrushItem* pCondBrush = &pPattern->GetItem(ATTR_BACKGROUND, pCondSet);
+ aBackColor = pCondBrush->GetColor();
+ bCondBackColor = true;
+ aPrevCellValue = aCellValue;
+ pPrevPattern = pPattern;
+ aPrevPatternColor = aBackColor;
+ }
}
}
}