[Libreoffice-commits] core.git: 2 commits - sw/source vcl/source

Stephan Bergmann sbergman at redhat.com
Tue Jan 13 01:08:37 PST 2015


 sw/source/core/view/viewsh.cxx |   14 ++++++++------
 vcl/source/outdev/map.cxx      |    8 +++++++-
 2 files changed, 15 insertions(+), 7 deletions(-)

New commits:
commit 482c57264708f783e70667fb1ac2d641cd25114a
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Jan 13 10:07:34 2015 +0100

    Improve ImplLogicToPixel overflow check
    
    Change-Id: Ib0554f6d489e410527d7bf4dc77f76db1bdbf1fc

diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx
index 5117471..7a9cc0c 100644
--- a/vcl/source/outdev/map.cxx
+++ b/vcl/source/outdev/map.cxx
@@ -17,7 +17,11 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <cstdlib>
 #include <limits.h>
+
 #include <o3tl/numeric.hxx>
 #include <tools/bigint.hxx>
 
@@ -382,7 +386,9 @@ static long ImplLogicToPixel( long n, long nDPI, long nMapNum, long nMapDenom,
     }
     else
 #else
-    assert(n < std::numeric_limits<long>::max() / nMapNum); //detect overflows
+    assert(nMapNum > 0);
+    assert(nDPI > 0);
+    assert(std::abs(n) < std::numeric_limits<long>::max() / nMapNum / nDPI); //detect overflows
 #endif
     {
        sal_Int64 n64 = n;
commit fd72427850d1f2db4d0b982391975d67b3e784fa
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Jan 13 10:02:57 2015 +0100

    Exclude FAR_AWAY objects from bounds computation
    
    ...otherwise, running CppunitTest_writerperfect_writer would overflow in
    ImplLogicToPixel (vcl/source/outdev/map.cxx) when nMaxRight would be
    ridiculously large due to including the ridiculously large right bound of an
    SwFlyLayFrm that is marked FAR_AWAY.
    
    Change-Id: Id6f8c895a953e99c5955b0f6ed655f8b79fba6f1

diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 580117f..9a5ff25 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -1085,12 +1085,14 @@ void SwViewShell::VisPortChgd( const SwRect &rRect)
                             if (pObj->IsFormatPossible())
                             {
                                 const Rectangle &rBound = pObj->GetObjRect().SVRect();
-                                // OD 03.03.2003 #107927# - use correct datatype
-                                const SwTwips nL = std::max( 0L, rBound.Left() - nOfst );
-                                if ( nL < nMinLeft )
-                                    nMinLeft = nL;
-                                if( rBound.Right() + nOfst > nMaxRight )
-                                    nMaxRight = rBound.Right() + nOfst;
+                                if (rBound.Left() != FAR_AWAY) {
+                                    // OD 03.03.2003 #107927# - use correct datatype
+                                    const SwTwips nL = std::max( 0L, rBound.Left() - nOfst );
+                                    if ( nL < nMinLeft )
+                                        nMinLeft = nL;
+                                    if( rBound.Right() + nOfst > nMaxRight )
+                                        nMaxRight = rBound.Right() + nOfst;
+                                }
                             }
                         }
                     }


More information about the Libreoffice-commits mailing list