From 462ff7cc65bebfd784a0472169e32c2a31566d62 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Thu, 15 Oct 2009 01:34:13 +0000 Subject: [PATCH] fixed: buffer overflow in Big::ToInt(Int & result) changed: small optimization in ToInt(Int & result) git-svn-id: svn://ttmath.org/publicrep/ttmath/trunk@210 e52654a7-88a9-db11-a3e9-0013d4bc506e --- CHANGELOG | 1 + ttmath/ttmathbig.h | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 09f1194..87b3947 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ Version 0.9.0 prerelease (2009.10.13): there was a buffer overflow when value_size was equal 1 * fixed: UInt::AddVector() and UInt::SubVector() didn't want to compile when macro TTMATH_NOASM was defined + * fixed: buffer overflow in Big::ToInt(Int & result) * added: support for wide characters (wchar_t, std::wstring) * added: Big::IsInteger() returns true if the value is integer (without fraction) diff --git a/ttmath/ttmathbig.h b/ttmath/ttmathbig.h index f1b5f93..c103110 100644 --- a/ttmath/ttmathbig.h +++ b/ttmath/ttmathbig.h @@ -2011,18 +2011,20 @@ public: if( exponent > maxbit + sint(int_size*TTMATH_BITS_PER_UINT) ) // if exponent > (maxbit + sint(int_size*TTMATH_BITS_PER_UINT)) the value can't be passed // into the 'Int' type (it's too big) + return 1; if( exponent <= maxbit ) // our value is from range (-1,1) and we return zero return 0; - UInt mantissa_temp(mantissa); sint how_many_bits = exponent.ToInt(); if( how_many_bits < 0 ) { how_many_bits = -how_many_bits; uint index = how_many_bits / TTMATH_BITS_PER_UINT; + + UInt mantissa_temp(mantissa); mantissa_temp.Rcr( how_many_bits % TTMATH_BITS_PER_UINT, 0 ); for(uint i=index, a=0 ; i