Browse Source

- previous commit was an older version of the function

Jan Janak 20 years ago
parent
commit
2550113bd7
1 changed files with 8 additions and 6 deletions
  1. 8 6
      modules/db_mysql/val.c

+ 8 - 6
modules/db_mysql/val.c

@@ -40,16 +40,18 @@
  */
 static inline int str2int(const char* _s, int* _v)
 {
+
 	long tmp;
 
-	if ((!_s) || (!_v)) {
-		LOG(L_ERR, "str2int: Invalid parameter value\n");
-		return -1;
+	if (!_s || !_v) {
+	       LOG(L_ERR, "str2int: Invalid parameter value\n");
+	       return -1;
 	}
 
-	tmp = strtol(_s, 0, 10);
-	if ((errno == ERANGE) || (tmp < INT_MIN || tmp > UINT_MAX)) {
-		LOG(L_ERR, "str2int: Value out of range\n");
+	tmp = strtoul(_s, 0, 10);
+	if ((tmp == ULONG_MAX && errno == ERANGE) || 
+	    (tmp < INT_MIN) || (tmp > UINT_MAX)) {
+		printf("str2int: Value out of range\n");
 		return -1;
 	}