using 'snprintf' in C99 (both for documentation of buffer sizes
and some complains from tools)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lobject.c,v 2.103 2015/03/28 19:14:47 roberto Exp roberto $
|
||||
** $Id: lobject.c,v 2.104 2015/04/11 18:30:08 roberto Exp roberto $
|
||||
** Some generic functions over Lua objects
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@@ -333,9 +333,9 @@ void luaO_tostring (lua_State *L, StkId obj) {
|
||||
size_t len;
|
||||
lua_assert(ttisnumber(obj));
|
||||
if (ttisinteger(obj))
|
||||
len = lua_integer2str(buff, ivalue(obj));
|
||||
len = lua_integer2str(buff, sizeof(buff), ivalue(obj));
|
||||
else {
|
||||
len = lua_number2str(buff, fltvalue(obj));
|
||||
len = lua_number2str(buff, sizeof(buff), fltvalue(obj));
|
||||
#if !defined(LUA_COMPAT_FLOATSTRING)
|
||||
if (buff[strspn(buff, "-0123456789")] == '\0') { /* looks like an int? */
|
||||
buff[len++] = lua_getlocaledecpoint();
|
||||
@@ -393,7 +393,7 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
|
||||
}
|
||||
case 'p': {
|
||||
char buff[4*sizeof(void *) + 8]; /* should be enough space for a '%p' */
|
||||
int l = sprintf(buff, "%p", va_arg(argp, void *));
|
||||
int l = l_sprintf(buff, sizeof(buff), "%p", va_arg(argp, void *));
|
||||
pushstr(L, buff, l);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user