sc/source/core/tool/address.cxx |   25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

New commits:
commit ec2a8205519bd546fe75c1b98bc1d8add8f2f2ec
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Mon Nov 11 11:07:12 2019 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Mon Nov 11 14:52:18 2019 +0100

    cid#1455325 Dereference after null check
    
    Change-Id: I5fa2846be23bcdfe202dd7c96fad79aa4009ff4e
    Reviewed-on: https://gerrit.libreoffice.org/82430
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>

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();
 }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to