diff --git a/src/lapi.c b/src/lapi.c index cb46379..51badd6 100644 --- a/src/lapi.c +++ b/src/lapi.c @@ -350,12 +350,13 @@ LUA_API int lua_toboolean (lua_State *L, int idx) { LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { StkId o = index2adr(L, idx); - if (ttissubstr(o) && len != NULL) { - /* if using lua_tostring, we need to convert to normal string so the cstring ends with \0 */ - /* otherwise, we can keep the substring intact */ + /*if (ttissubstr(o) && len != NULL) { + / * ~~if using lua_tostring, we need to convert to normal string so the cstring ends with \0 * / + / * otherwise, we can keep the substring intact~~ * / + / * EDIT: this breaks Lua spec - we're always doing this * / *len = ssvalue(o)->len; return getstr(ssvalue(o)->str) + ssvalue(o)->offset; - } + }*/ if (!ttisstring(o)) { lua_lock(L); /* `luaV_tostring' may create a new string */ if (!luaV_tostring(L, o)) { /* conversion failed? */ diff --git a/src/lstrlib.c b/src/lstrlib.c index fa6fad8..e20d2e3 100644 --- a/src/lstrlib.c +++ b/src/lstrlib.c @@ -850,7 +850,7 @@ static int str_format (lua_State *L) { continue; /* skip the `addsize' at the end */ } else { - sprintf(buff, form, s); + snprintf(buff, MAX_ITEM, form, s); lua_pop(L, 1); break; }