aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2011-07-27 09:13:08 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2011-07-27 09:13:08 -0300
commit03a078493ebfb9a85aea44594ca3a90f9d297f85 (patch)
treef62338a0358259fb3cdd40e472070663ac47c215
parentbae57ea088504146883323c1bc122a74b34760c3 (diff)
downloadlua-03a078493ebfb9a85aea44594ca3a90f9d297f85.tar.gz
lua-03a078493ebfb9a85aea44594ca3a90f9d297f85.tar.bz2
lua-03a078493ebfb9a85aea44594ca3a90f9d297f85.zip
refuse things like 'inf' or 'Nan' as numerals
-rw-r--r--lobject.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/lobject.c b/lobject.c
index 54c82d2c..fdbf7f76 100644
--- a/lobject.c
+++ b/lobject.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.c,v 2.51 2011/06/23 16:01:06 roberto Exp roberto $ 2** $Id: lobject.c,v 2.53 2011/07/27 12:09:13 roberto Exp roberto $
3** Some generic functions over Lua objects 3** Some generic functions over Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -103,8 +103,8 @@ static int isneg (const char **s) {
103 103
104 104
105static lua_Number readhexa (const char **s, lua_Number r, int *count) { 105static lua_Number readhexa (const char **s, lua_Number r, int *count) {
106 while (lisxdigit(cast_uchar(**s))) { /* read integer part */ 106 for (; lisxdigit(cast_uchar(**s)); (*s)++) { /* read integer part */
107 r = (r * 16.0) + cast_num(luaO_hexavalue(cast_uchar(*(*s)++))); 107 r = (r * 16.0) + cast_num(luaO_hexavalue(cast_uchar(**s)));
108 (*count)++; 108 (*count)++;
109 } 109 }
110 return r; 110 return r;
@@ -157,7 +157,9 @@ static lua_Number lua_strx2number (const char *s, char **endptr) {
157 157
158int luaO_str2d (const char *s, size_t len, lua_Number *result) { 158int luaO_str2d (const char *s, size_t len, lua_Number *result) {
159 char *endptr; 159 char *endptr;
160 if (strpbrk(s, "xX")) /* hexa? */ 160 if (strpbrk(s, "nN")) /* reject 'inf' and 'nan' */
161 return 0;
162 else if (strpbrk(s, "xX")) /* hexa? */
161 *result = lua_strx2number(s, &endptr); 163 *result = lua_strx2number(s, &endptr);
162 else 164 else
163 *result = lua_str2number(s, &endptr); 165 *result = lua_str2number(s, &endptr);