mirror of
https://github.com/lua/lua
synced 2026-09-27 00:28:25 +03:00
ensure argument to 'string.format("%s")' does not contain zeros
This commit is contained in:
parent
c5112f7b15
commit
3feb702df8
1 changed files with 2 additions and 1 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lstrlib.c,v 1.236 2015/10/28 17:56:51 roberto Exp roberto $
|
||||
** $Id: lstrlib.c,v 1.237 2015/10/29 15:11:41 roberto Exp roberto $
|
||||
** Standard library for string operations and pattern-matching
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
|
@ -1031,6 +1031,7 @@ static int str_format (lua_State *L) {
|
|||
case 's': {
|
||||
size_t l;
|
||||
const char *s = luaL_tolstring(L, arg, &l);
|
||||
luaL_argcheck(L, l == strlen(s), arg, "string cannot contain zeros");
|
||||
if (!strchr(form, '.') && l >= 100) {
|
||||
/* no precision and string is too long to be formatted;
|
||||
keep original string */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue