diff --git a/src/OpenFOAM/primitives/ints/int/intIO.C b/src/OpenFOAM/primitives/ints/int/intIO.C
index bd02519..74243d4 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 <sstream>
+#include <cerrno>
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -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);
 }
 
 
