Change mantissa iterators that rely on out-of-bounds indices back to pointers

This commit is contained in:
fwcd 2019-04-06 21:13:12 +02:00
commit cf8898eda6
2 changed files with 11 additions and 11 deletions

View file

@ -386,7 +386,7 @@ PNUMBER numtonRadixx(_In_ PNUMBER a, uint32_t radix)
{ {
PNUMBER pnumret = i32tonum(0, BASEX); // pnumret is the number in internal form. PNUMBER pnumret = i32tonum(0, BASEX); // pnumret is the number in internal form.
PNUMBER num_radix = i32tonum(radix, BASEX); PNUMBER num_radix = i32tonum(radix, BASEX);
vector<MANTTYPE>::iterator ptrdigit = a->mant.begin(); // iterator pointing to digit being worked on. MANTTYPE *ptrdigit = a->mant.data(); // pointer to digit being worked on.
// Digits are in reverse order, back over them LSD first. // Digits are in reverse order, back over them LSD first.
ptrdigit += a->cdigit-1; ptrdigit += a->cdigit-1;
@ -1037,7 +1037,7 @@ int32_t numtoi32( _In_ PNUMBER pnum, uint32_t radix )
{ {
int32_t lret = 0; int32_t lret = 0;
vector<MANTTYPE>::iterator pmant = pnum->mant.begin(); MANTTYPE *pmant = pnum->mant.data();
pmant += pnum->cdigit - 1; pmant += pnum->cdigit - 1;
int32_t expt = pnum->exp; int32_t expt = pnum->exp;
@ -1209,7 +1209,7 @@ wstring NumberToString(_Inout_ PNUMBER& pnum, int format, uint32_t radix, int32_
// Set up all the post rounding stuff. // Set up all the post rounding stuff.
bool useSciForm = false; bool useSciForm = false;
int32_t eout = exponent - 1; // Displayed exponent. int32_t eout = exponent - 1; // Displayed exponent.
vector<MANTTYPE>::iterator pmant = pnum->mant.begin() + pnum->cdigit - 1; MANTTYPE *pmant = pnum->mant.data() + pnum->cdigit - 1;
// Case where too many digits are to the left of the decimal or // Case where too many digits are to the left of the decimal or
// FMT_SCIENTIFIC or FMT_ENGINEERING was specified. // FMT_SCIENTIFIC or FMT_ENGINEERING was specified.
if ((format == FMT_SCIENTIFIC) || (format == FMT_ENGINEERING)) if ((format == FMT_SCIENTIFIC) || (format == FMT_ENGINEERING))

View file

@ -506,8 +506,8 @@ bool equnum( PNUMBER a, PNUMBER b )
{ {
int32_t diff; int32_t diff;
vector<MANTTYPE>::iterator pa; MANTTYPE *pa;
vector<MANTTYPE>::iterator pb; MANTTYPE *pb;
int32_t cdigits; int32_t cdigits;
int32_t ccdigits; int32_t ccdigits;
MANTTYPE da; MANTTYPE da;
@ -529,8 +529,8 @@ bool equnum( PNUMBER a, PNUMBER b )
else else
{ {
// OK the exponents match. // OK the exponents match.
pa = a->mant.begin(); pa = a->mant.data();
pb = b->mant.begin(); pb = b->mant.data();
pa += a->cdigit - 1; pa += a->cdigit - 1;
pb += b->cdigit - 1; pb += b->cdigit - 1;
cdigits = max( a->cdigit, b->cdigit ); cdigits = max( a->cdigit, b->cdigit );
@ -574,8 +574,8 @@ bool lessnum( PNUMBER a, PNUMBER b )
{ {
int32_t diff; int32_t diff;
vector<MANTTYPE>::iterator pa; MANTTYPE *pa;
vector<MANTTYPE>::iterator pb; MANTTYPE *pb;
int32_t cdigits; int32_t cdigits;
int32_t ccdigits; int32_t ccdigits;
MANTTYPE da; MANTTYPE da;
@ -596,8 +596,8 @@ bool lessnum( PNUMBER a, PNUMBER b )
} }
else else
{ {
pa = a->mant.begin(); pa = a->mant.data();
pb = b->mant.begin(); pb = b->mant.data();
pa += a->cdigit - 1; pa += a->cdigit - 1;
pb += b->cdigit - 1; pb += b->cdigit - 1;
cdigits = max( a->cdigit, b->cdigit ); cdigits = max( a->cdigit, b->cdigit );