Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


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.mohrhard@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


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.