Hey,

the attached patch fixes a crash in our rtl::math lib. For
std::numeric_limits<int>::min() -nExp is the same as nExp and
therefore we would be in the first case and try to access a non
existing element.

Any objections against this patch? I think that this fix should be
correct for all cases but it would be good if someone could have a
look at it.

Regards,
Markus
From f3f36bb41509a3dc72f170b141c06a6de1dd52fa Mon Sep 17 00:00:00 2001
From: Markus Mohrhard <markus.mohrh...@googlemail.com>
Date: Tue, 13 Dec 2011 00:09:42 +0100
Subject: [PATCH] fix crash for std::numeric_limits<int>::min() in our math lib impl

---
 sal/rtl/source/math.cxx |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sal/rtl/source/math.cxx b/sal/rtl/source/math.cxx
index 947f733..d118dde 100644
--- a/sal/rtl/source/math.cxx
+++ b/sal/rtl/source/math.cxx
@@ -59,7 +59,7 @@ static double getN10Exp( int nExp )
 {
     if ( nExp < 0 )
     {
-        if ( -nExp <= n10Count )
+        if ( -nExp <= n10Count && -nExp > 0 )
             return n10s[1][-nExp-1];
         else
             return pow( 10.0, static_cast<double>( nExp ) );
-- 
1.7.3.4

_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to