aboutsummaryrefslogtreecommitdiff
path: root/lobject.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-11-03 16:34:36 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-11-03 16:34:36 -0300
commit58216600eba27d472de33dbb89e2f3e629bf8a59 (patch)
tree9504237097bb72548e5e7b66b753dc23056330a8 /lobject.c
parent94cbe4651156a84dd9114d7daaa61acd050adbe0 (diff)
downloadlua-58216600eba27d472de33dbb89e2f3e629bf8a59.tar.gz
lua-58216600eba27d472de33dbb89e2f3e629bf8a59.tar.bz2
lua-58216600eba27d472de33dbb89e2f3e629bf8a59.zip
'luaL_newstate' should not allocate extra memory
The allocation of a userdata for the state of the warn system can cause a panic if it fails; 'luaL_ref' also can fail. This commit re-implements the warn system so that it does not need an explicit state. Instead, the system uses different functions to represent the different states.
Diffstat (limited to 'lobject.c')
-rw-r--r--lobject.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lobject.c b/lobject.c
index f8ea917a..0e504be0 100644
--- a/lobject.c
+++ b/lobject.c
@@ -258,7 +258,7 @@ static const char *l_str2d (const char *s, lua_Number *result) {
258 if (endptr == NULL) { /* failed? may be a different locale */ 258 if (endptr == NULL) { /* failed? may be a different locale */
259 char buff[L_MAXLENNUM + 1]; 259 char buff[L_MAXLENNUM + 1];
260 const char *pdot = strchr(s, '.'); 260 const char *pdot = strchr(s, '.');
261 if (strlen(s) > L_MAXLENNUM || pdot == NULL) 261 if (pdot == NULL || strlen(s) > L_MAXLENNUM)
262 return NULL; /* string too long or no dot; fail */ 262 return NULL; /* string too long or no dot; fail */
263 strcpy(buff, s); /* copy string to buffer */ 263 strcpy(buff, s); /* copy string to buffer */
264 buff[pdot - s] = lua_getlocaledecpoint(); /* correct decimal point */ 264 buff[pdot - s] = lua_getlocaledecpoint(); /* correct decimal point */