reset errno to 0 before calling strtol (resolves issue 128)

ref:#128
master
Yanbiao Li 2017-04-25 03:29:18 +08:00
parent fa76ed2ba3
commit 2e57a20c9f
2 changed files with 2 additions and 0 deletions

View File

@ -36,6 +36,7 @@ mystrtol(const char *nptr, int base)
int rval;
char *endptr;
errno = 0;
rval = strtol(nptr, &endptr, 10);
/* check for strtol errors */
if ((errno == ERANGE && (rval == LONG_MAX ||

View File

@ -241,6 +241,7 @@ mystrtol(const char *nptr, int base)
int rval;
char *endptr;
errno = 0;
rval = strtol(nptr, &endptr, 10);
/* check for strtol errors */
if ((errno == ERANGE && (rval == LONG_MAX ||