From: Victor Stinner Date: Mon, 16 Dec 2013 22:06:19 +0000 (+0100) Subject: tracemalloc: fix usage of strtol(), value can be LONG_MIN or LONG_MAX on ERANGE X-Git-Tag: v3.4.0b2~195 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=711e27cd503933cfe7a42d931d2b69dc79014ae0;p=thirdparty%2FPython%2Fcpython.git tracemalloc: fix usage of strtol(), value can be LONG_MIN or LONG_MAX on ERANGE --- diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c index 7e6113dc1ae2..f8ce76625181 100644 --- a/Modules/_tracemalloc.c +++ b/Modules/_tracemalloc.c @@ -1373,11 +1373,12 @@ _PyTraceMalloc_Init(void) char *endptr = p; long value; + errno = 0; value = strtol(p, &endptr, 10); if (*endptr != '\0' || value < 1 || value > MAX_NFRAME - || (errno == ERANGE && value == ULONG_MAX)) + || errno == ERANGE) { Py_FatalError("PYTHONTRACEMALLOC: invalid number of frames"); return -1;