diff --git a/src/OpenFOAM/primitives/ints/int/intIO.C b/src/OpenFOAM/primitives/ints/int/intIO.C index bd025198..74243d41 100644 --- a/src/OpenFOAM/primitives/ints/int/intIO.C +++ b/src/OpenFOAM/primitives/ints/int/intIO.C @@ -35,6 +35,7 @@ Description #include "IOstreams.H" #include +#include // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -91,9 +92,10 @@ int Foam::readInt(Istream& is) bool Foam::readInt(const char* buf, int& s) { char *endptr = NULL; + errno = 0; long l = strtol(buf, &endptr, 10); s = int(l); - return (*endptr == 0); + return (*endptr == 0) && (errno == 0) && (l >= INT_MIN) && (l <= INT_MAX); }