summaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-08-25 15:50:37 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-08-25 15:50:37 -0300
commit502214f8a551cd01d94677f98a40aa51531ef71d (patch)
tree479ae6561917389acc9d11f00a767c2e40745302 /lapi.c
parented19fe766cf833e80236a6aaec63137744f60562 (diff)
downloadlua-github-502214f8a551cd01d94677f98a40aa51531ef71d.tar.gz
added assert for NULL pointer in 'lua_pushlstring'
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lapi.c b/lapi.c
index 80e89f12..bd4efaa3 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
/*
-** $Id: lapi.c,v 2.252 2015/08/03 19:50:49 roberto Exp roberto $
+** $Id: lapi.c,v 2.253 2015/08/03 20:40:26 roberto Exp roberto $
** Lua API
** See Copyright Notice in lua.h
*/
@@ -471,10 +471,15 @@ LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
}
+/*
+** Pushes on the stack a string with given length. Even when 'len' == 0,
+** 's' cannot be NULL due to later use of 'memcmp' and 'memcpy'.
+*/
LUA_API const char *lua_pushlstring (lua_State *L, const char *s, size_t len) {
TString *ts;
lua_lock(L);
luaC_checkGC(L);
+ api_check(L, s != NULL, "pointer cannot be NULL");
ts = luaS_newlstr(L, s, len);
setsvalue2s(L, L->top, ts);
api_incr_top(L);