Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77140 - sandbox/big_number/boost/multiprecision
From: john_at_[hidden]
Date: 2012-02-29 05:42:24


Author: johnmaddock
Date: 2012-02-29 05:42:23 EST (Wed, 29 Feb 2012)
New Revision: 77140
URL: http://svn.boost.org/trac/boost/changeset/77140

Log:
Fix memory leaks / bugs in mpq_t and tommath support.
Text files modified:
   sandbox/big_number/boost/multiprecision/gmp.hpp | 4 ++--
   sandbox/big_number/boost/multiprecision/tommath.hpp | 3 ++-
   2 files changed, 4 insertions(+), 3 deletions(-)

Modified: sandbox/big_number/boost/multiprecision/gmp.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/gmp.hpp (original)
+++ sandbox/big_number/boost/multiprecision/gmp.hpp 2012-02-29 05:42:23 EST (Wed, 29 Feb 2012)
@@ -1460,7 +1460,7 @@
       unsigned long long mask = ((1uLL << std::numeric_limits<unsigned>::digits) - 1);
       unsigned shift = 0;
       mpq_t t;
- mpq_init(m_data);
+ mpq_set_ui(m_data, 0, 1);
       mpq_init(t);
       while(i)
       {
@@ -1521,7 +1521,7 @@
 
       int e;
       long double f, term;
- mpq_init(m_data);
+ mpq_set_ui(m_data, 0, 1);
       mpq_set_ui(m_data, 0u, 1);
       gmp_rational t;
 

Modified: sandbox/big_number/boost/multiprecision/tommath.hpp
==============================================================================
--- sandbox/big_number/boost/multiprecision/tommath.hpp (original)
+++ sandbox/big_number/boost/multiprecision/tommath.hpp 2012-02-29 05:42:23 EST (Wed, 29 Feb 2012)
@@ -117,7 +117,7 @@
 
       int e;
       long double f, term;
- detail::check_tommath_result(mp_init_set_int(&m_data, 0u));
+ detail::check_tommath_result(mp_set_int(&m_data, 0u));
       ::mp_int t;
       detail::check_tommath_result(mp_init(&t));
 
@@ -151,6 +151,7 @@
          tommath_int t2;
          detail::check_tommath_result(mp_div_2d(&m_data, -e, &m_data, &t2.data()));
       }
+ mp_clear(&t);
       return *this;
    }
    tommath_int& operator = (const char* s)


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk