mirror of
https://github.com/lua/lua
synced 2025-01-09 02:52:33 +03:00
refuse things like 'inf' or 'Nan' as numerals
This commit is contained in:
parent
bae57ea088
commit
03a078493e
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
|
||||
** 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) {
|
||||
while (lisxdigit(cast_uchar(**s))) { /* read integer part */
|
||||
r = (r * 16.0) + cast_num(luaO_hexavalue(cast_uchar(*(*s)++)));
|
||||
for (; lisxdigit(cast_uchar(**s)); (*s)++) { /* read integer part */
|
||||
r = (r * 16.0) + cast_num(luaO_hexavalue(cast_uchar(**s)));
|
||||
(*count)++;
|
||||
}
|
||||
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) {
|
||||
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);
|
||||
else
|
||||
*result = lua_str2number(s, &endptr);
|
||||
|
Loading…
Reference in New Issue
Block a user