summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-11-11 11:07:12 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-11-11 14:52:18 +0100
commitec2a8205519bd546fe75c1b98bc1d8add8f2f2ec (patch)
treedea039c4295f47c8ac7616b4cdab738e776b5f95
parent6755977f590ffcef629f8ccee7675a8368a2ea83 (diff)
cid#1455325 Dereference after null check
Change-Id: I5fa2846be23bcdfe202dd7c96fad79aa4009ff4e Reviewed-on: https://gerrit.libreoffice.org/82430 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sc/source/core/tool/address.cxx25
1 files changed, 17 insertions, 8 deletions
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index b210e7bedc03..e38bdc6d68fa 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -2234,20 +2234,23 @@ OUString ScRange::Format( ScRefFlags nFlags, const ScDocument* pDoc,
r.append(":");
r.append(aName);
}
+ break;
}
- break;
case formula::FormulaGrammar::CONV_XL_A1:
- case formula::FormulaGrammar::CONV_XL_OOX:
+ case formula::FormulaGrammar::CONV_XL_OOX: {
+ SCCOL nMaxCol = pDoc ? pDoc->MaxCol() : MAXCOL;
+ SCROW nMaxRow = pDoc ? pDoc->MaxRow() : MAXROW;
+
lcl_ScRange_Format_XL_Header( r, *this, nFlags, pDoc, rDetails );
- if( aStart.Col() == 0 && aEnd.Col() >= (pDoc ? pDoc->MaxCol() : MAXCOL) && !bFullAddressNotation )
+ if( aStart.Col() == 0 && aEnd.Col() >= nMaxCol && !bFullAddressNotation )
{
// Full col refs always require 2 rows (2:2)
lcl_a1_append_r( r, aStart.Row(), (nFlags & ScRefFlags::ROW_ABS) != ScRefFlags::ZERO );
r.append(":");
lcl_a1_append_r( r, aEnd.Row(), (nFlags & ScRefFlags::ROW2_ABS) != ScRefFlags::ZERO );
}
- else if( aStart.Row() == 0 && aEnd.Row() >= pDoc->MaxRow() && !bFullAddressNotation )
+ else if( aStart.Row() == 0 && aEnd.Row() >= nMaxRow && !bFullAddressNotation )
{
// Full row refs always require 2 cols (A:A)
lcl_a1_append_c( r, aStart.Col(), (nFlags & ScRefFlags::COL_ABS) != ScRefFlags::ZERO );
@@ -2267,11 +2270,15 @@ OUString ScRange::Format( ScRefFlags nFlags, const ScDocument* pDoc,
lcl_a1_append_r ( r, aEnd.Row(), (nFlags & ScRefFlags::ROW2_ABS) != ScRefFlags::ZERO );
}
}
- break;
+ break;
+ }
+
+ case formula::FormulaGrammar::CONV_XL_R1C1: {
+ SCCOL nMaxCol = pDoc ? pDoc->MaxCol() : MAXCOL;
+ SCROW nMaxRow = pDoc ? pDoc->MaxRow() : MAXROW;
- case formula::FormulaGrammar::CONV_XL_R1C1:
lcl_ScRange_Format_XL_Header( r, *this, nFlags, pDoc, rDetails );
- if( aStart.Col() == 0 && aEnd.Col() >= (pDoc ? pDoc->MaxCol() : MAXCOL) && !bFullAddressNotation )
+ if( aStart.Col() == 0 && aEnd.Col() >= nMaxCol && !bFullAddressNotation )
{
lcl_r1c1_append_r( r, aStart.Row(), (nFlags & ScRefFlags::ROW_ABS) != ScRefFlags::ZERO, rDetails );
if( aStart.Row() != aEnd.Row() ||
@@ -2280,7 +2287,7 @@ OUString ScRange::Format( ScRefFlags nFlags, const ScDocument* pDoc,
lcl_r1c1_append_r( r, aEnd.Row(), (nFlags & ScRefFlags::ROW2_ABS) != ScRefFlags::ZERO, rDetails );
}
}
- else if( aStart.Row() == 0 && aEnd.Row() >= pDoc->MaxRow() && !bFullAddressNotation )
+ else if( aStart.Row() == 0 && aEnd.Row() >= nMaxRow && !bFullAddressNotation )
{
lcl_r1c1_append_c( r, aStart.Col(), (nFlags & ScRefFlags::COL_ABS) != ScRefFlags::ZERO, rDetails );
if( aStart.Col() != aEnd.Col() ||
@@ -2302,6 +2309,8 @@ OUString ScRange::Format( ScRefFlags nFlags, const ScDocument* pDoc,
lcl_r1c1_append_c( r, aEnd.Col(), (nFlags & ScRefFlags::COL2_ABS) != ScRefFlags::ZERO, rDetails );
}
}
+ break;
+ }
}
return r.makeStringAndClear();
}