tracemalloc: fix usage of strtol(), value can be LONG_MIN or LONG_MAX on ERANGE

This commit is contained in:
Victor Stinner 2013-12-16 23:06:19 +01:00
parent 4d8c29cd57
commit 711e27cd50
1 changed files with 2 additions and 1 deletions

View File

@ -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;