Browse Source

Bugfix: get_intrange: Check for extra garbage at the end, only after we know we have an end-position

Luke Dashjr 12 years ago
parent
commit
ddb62b8d03
1 changed files with 4 additions and 3 deletions
  1. 4 3
      miner.c

+ 4 - 3
miner.c

@@ -753,8 +753,6 @@ bool get_intrange(const char *arg, int *val1, int *val2)
 	int pos, n;
 	int pos, n;
 	// Is is unclear whether %n is counted in the returned value, so %n is doubled up to make 2 unambiguous
 	// Is is unclear whether %n is counted in the returned value, so %n is doubled up to make 2 unambiguous
 	n = sscanf(arg, "%d%n%n -%d %n", val1, &pos, &pos, val2, &pos);
 	n = sscanf(arg, "%d%n%n -%d %n", val1, &pos, &pos, val2, &pos);
-	if (unlikely(arg[pos]))
-		return false;
 	switch (n)
 	switch (n)
 	{
 	{
 		case 1:  // %n not counted (only one number)
 		case 1:  // %n not counted (only one number)
@@ -762,10 +760,13 @@ bool get_intrange(const char *arg, int *val1, int *val2)
 			*val2 = *val1;
 			*val2 = *val1;
 		case 2:  // %n not counted (two numbers)
 		case 2:  // %n not counted (two numbers)
 		case 5:  // %n     counted
 		case 5:  // %n     counted
-			return true;
+			break;
 		default:
 		default:
 			return false;
 			return false;
 	}
 	}
+	if (unlikely(arg[pos]))
+		return false;
+	return true;
 }
 }
 
 
 static
 static