mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
Change a variable type to avoid signed overflow; replace repeated '19999' constant by a define.
This commit is contained in:
parent
e822ab0166
commit
0ca7452794
1 changed files with 10 additions and 4 deletions
|
@ -200,6 +200,13 @@ typedef union { double d; ULong L[2]; } U;
|
||||||
#define STRTOD_DIGLIM 40
|
#define STRTOD_DIGLIM 40
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* maximum permitted exponent value for strtod; exponents larger than
|
||||||
|
MAX_ABS_EXP in absolute value get truncated to +-MAX_ABS_EXP. MAX_ABS_EXP
|
||||||
|
should fit into an int. */
|
||||||
|
#ifndef MAX_ABS_EXP
|
||||||
|
#define MAX_ABS_EXP 19999U
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The following definition of Storeinc is appropriate for MIPS processors.
|
/* The following definition of Storeinc is appropriate for MIPS processors.
|
||||||
* An alternative that might be better on some machines is
|
* An alternative that might be better on some machines is
|
||||||
* #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)
|
* #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)
|
||||||
|
@ -1305,9 +1312,8 @@ _Py_dg_strtod(const char *s00, char **se)
|
||||||
int esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
|
int esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
|
||||||
const char *s, *s0, *s1;
|
const char *s, *s0, *s1;
|
||||||
double aadj, aadj1;
|
double aadj, aadj1;
|
||||||
Long L;
|
|
||||||
U aadj2, adj, rv, rv0;
|
U aadj2, adj, rv, rv0;
|
||||||
ULong y, z;
|
ULong y, z, L;
|
||||||
BCinfo bc;
|
BCinfo bc;
|
||||||
Bigint *bb, *bb1, *bd, *bd0, *bs, *delta;
|
Bigint *bb, *bb1, *bd, *bd0, *bs, *delta;
|
||||||
|
|
||||||
|
@ -1406,11 +1412,11 @@ _Py_dg_strtod(const char *s00, char **se)
|
||||||
s1 = s;
|
s1 = s;
|
||||||
while((c = *++s) >= '0' && c <= '9')
|
while((c = *++s) >= '0' && c <= '9')
|
||||||
L = 10*L + c - '0';
|
L = 10*L + c - '0';
|
||||||
if (s - s1 > 8 || L > 19999)
|
if (s - s1 > 8 || L > MAX_ABS_EXP)
|
||||||
/* Avoid confusion from exponents
|
/* Avoid confusion from exponents
|
||||||
* so large that e might overflow.
|
* so large that e might overflow.
|
||||||
*/
|
*/
|
||||||
e = 19999; /* safe for 16 bit ints */
|
e = (int)MAX_ABS_EXP; /* safe for 16 bit ints */
|
||||||
else
|
else
|
||||||
e = (int)L;
|
e = (int)L;
|
||||||
if (esign)
|
if (esign)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue