[Libreoffice-commits] core.git: svx/source

Caolán McNamara caolanm at redhat.com
Fri Apr 7 09:01:43 UTC 2017


 svx/source/table/tablelayouter.cxx |   31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

New commits:
commit fef765d68d090bb439f58347afc930f48567673e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Mar 31 11:23:04 2017 +0100

    ofz#974 check SetBorder bounds like the other maHorizontalBorders users
    
    Change-Id: Iac113433ac2317ddfebc68ed793c481384d56551
    Reviewed-on: https://gerrit.libreoffice.org/35964
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/svx/source/table/tablelayouter.cxx b/svx/source/table/tablelayouter.cxx
index ae588b11a5aa..3c08c79e085a 100644
--- a/svx/source/table/tablelayouter.cxx
+++ b/svx/source/table/tablelayouter.cxx
@@ -916,36 +916,40 @@ bool TableLayouter::HasPriority( const SvxBorderLine* pThis, const SvxBorderLine
     }
 }
 
-
 void TableLayouter::SetBorder( sal_Int32 nCol, sal_Int32 nRow, bool bHorizontal, const SvxBorderLine* pLine )
 {
-    if( pLine == nullptr )
+    if (!pLine)
         pLine = &gEmptyBorder;
 
-    SvxBorderLine *pOld = bHorizontal ? maHorizontalBorders[nCol][nRow] : maVerticalBorders[nCol][nRow];
+    BorderLineMap& rMap = bHorizontal ? maHorizontalBorders : maVerticalBorders;
 
-    if( HasPriority( pLine, pOld ) )
+    if( (nCol >= 0) && (nCol < sal::static_int_cast<sal_Int32>(rMap.size())) &&
+        (nRow >= 0) && (nRow < sal::static_int_cast<sal_Int32>(rMap[nCol].size())) )
     {
-        if( (pOld != nullptr) && (pOld != &gEmptyBorder) )
-            delete pOld;
+        SvxBorderLine *pOld = rMap[nCol][nRow];
 
-        SvxBorderLine* pNew = ( pLine != &gEmptyBorder ) ?  new SvxBorderLine(*pLine) : &gEmptyBorder;
+        if (HasPriority(pLine, pOld))
+        {
+            if (pOld && pOld != &gEmptyBorder)
+                delete pOld;
 
-        if( bHorizontal )
-            maHorizontalBorders[nCol][nRow] = pNew;
-        else
-            maVerticalBorders[nCol][nRow]  = pNew;
+            SvxBorderLine* pNew = (pLine != &gEmptyBorder) ?  new SvxBorderLine(*pLine) : &gEmptyBorder;
+
+            rMap[nCol][nRow] = pNew;
+        }
+    }
+    else
+    {
+        OSL_FAIL( "sdr::table::TableLayouter::SetBorder(), invalid border!" );
     }
 }
 
-
 void TableLayouter::ClearBorderLayout()
 {
     ClearBorderLayout(maHorizontalBorders);
     ClearBorderLayout(maVerticalBorders);
 }
 
-
 void TableLayouter::ClearBorderLayout(BorderLineMap& rMap)
 {
     const sal_Int32 nColCount = rMap.size();
@@ -967,7 +971,6 @@ void TableLayouter::ClearBorderLayout(BorderLineMap& rMap)
     }
 }
 
-
 void TableLayouter::ResizeBorderLayout()
 {
     ClearBorderLayout();


More information about the Libreoffice-commits mailing list