refuse things like 'inf' or 'Nan' as numerals
This commit is contained in:
10
lobject.c
10
lobject.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lobject.c,v 2.51 2011/06/23 16:01:06 roberto Exp roberto $
|
** $Id: lobject.c,v 2.53 2011/07/27 12:09:13 roberto Exp roberto $
|
||||||
** Some generic functions over Lua objects
|
** Some generic functions over Lua objects
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -103,8 +103,8 @@ static int isneg (const char **s) {
|
|||||||
|
|
||||||
|
|
||||||
static lua_Number readhexa (const char **s, lua_Number r, int *count) {
|
static lua_Number readhexa (const char **s, lua_Number r, int *count) {
|
||||||
while (lisxdigit(cast_uchar(**s))) { /* read integer part */
|
for (; lisxdigit(cast_uchar(**s)); (*s)++) { /* read integer part */
|
||||||
r = (r * 16.0) + cast_num(luaO_hexavalue(cast_uchar(*(*s)++)));
|
r = (r * 16.0) + cast_num(luaO_hexavalue(cast_uchar(**s)));
|
||||||
(*count)++;
|
(*count)++;
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
@@ -157,7 +157,9 @@ static lua_Number lua_strx2number (const char *s, char **endptr) {
|
|||||||
|
|
||||||
int luaO_str2d (const char *s, size_t len, lua_Number *result) {
|
int luaO_str2d (const char *s, size_t len, lua_Number *result) {
|
||||||
char *endptr;
|
char *endptr;
|
||||||
if (strpbrk(s, "xX")) /* hexa? */
|
if (strpbrk(s, "nN")) /* reject 'inf' and 'nan' */
|
||||||
|
return 0;
|
||||||
|
else if (strpbrk(s, "xX")) /* hexa? */
|
||||||
*result = lua_strx2number(s, &endptr);
|
*result = lua_strx2number(s, &endptr);
|
||||||
else
|
else
|
||||||
*result = lua_str2number(s, &endptr);
|
*result = lua_str2number(s, &endptr);
|
||||||
|
|||||||
Reference in New Issue
Block a user