commit 57e91b4159082b8cbda54e38c80117a954af154a
parent ef7d29c66601ac2484ce474fde9b058b3dd4eaa0
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Thu, 11 Dec 2014 12:02:42 -0200
correct computation for limit in 'getnum'
Diffstat:
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lstrlib.c b/lstrlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lstrlib.c,v 1.219 2014/12/10 11:36:03 roberto Exp roberto $
+** $Id: lstrlib.c,v 1.220 2014/12/11 13:40:40 roberto Exp roberto $
** Standard library for string operations and pattern-matching
** See Copyright Notice in lua.h
*/
@@ -1034,8 +1034,8 @@ static int getnum (const char **fmt, int df) {
else {
int a = 0;
do {
- a = a*10 + *((*fmt)++) - '0';
- } while (digit(**fmt) && a < ((int)MAXSIZE/10 - 10));
+ a = a*10 + (*((*fmt)++) - '0');
+ } while (digit(**fmt) && a <= ((int)MAXSIZE - 9)/10);
return a;
}
}