aboutsummaryrefslogtreecommitdiff
path: root/lstrlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-11-23 09:31:21 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-11-23 09:31:21 -0200
commit3feb702df8b362d3d3a4bdeda48313da1278ebe4 (patch)
treea2a03469e472d985c70c24932f3c8293ae5c7922 /lstrlib.c
parentc5112f7b156ad2565bad3035c8c4008c3e7716a4 (diff)
downloadlua-3feb702df8b362d3d3a4bdeda48313da1278ebe4.tar.gz
lua-3feb702df8b362d3d3a4bdeda48313da1278ebe4.tar.bz2
lua-3feb702df8b362d3d3a4bdeda48313da1278ebe4.zip
ensure argument to 'string.format("%s")' does not contain zeros
Diffstat (limited to 'lstrlib.c')
-rw-r--r--lstrlib.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lstrlib.c b/lstrlib.c
index ff5cdd77..1bc26829 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstrlib.c,v 1.236 2015/10/28 17:56:51 roberto Exp roberto $ 2** $Id: lstrlib.c,v 1.237 2015/10/29 15:11:41 roberto Exp roberto $
3** Standard library for string operations and pattern-matching 3** Standard library for string operations and pattern-matching
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -1031,6 +1031,7 @@ static int str_format (lua_State *L) {
1031 case 's': { 1031 case 's': {
1032 size_t l; 1032 size_t l;
1033 const char *s = luaL_tolstring(L, arg, &l); 1033 const char *s = luaL_tolstring(L, arg, &l);
1034 luaL_argcheck(L, l == strlen(s), arg, "string cannot contain zeros");
1034 if (!strchr(form, '.') && l >= 100) { 1035 if (!strchr(form, '.') && l >= 100) {
1035 /* no precision and string is too long to be formatted; 1036 /* no precision and string is too long to be formatted;
1036 keep original string */ 1037 keep original string */