aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2014-05-15 19:09:47 -0400
committerShadowNinja <shadowninja@minetest.net>2014-05-15 19:09:47 -0400
commit34d872628d5099ae520dd92433e211f561aaf611 (patch)
tree534017e582f4e398ae86226b7d8e8ef31e8449d2 /src/script
parentc8a99404e8c52a59127bdd634b13f10f7ebb19ab (diff)
downloadminetest-34d872628d5099ae520dd92433e211f561aaf611.tar.gz
minetest-34d872628d5099ae520dd92433e211f561aaf611.tar.bz2
minetest-34d872628d5099ae520dd92433e211f561aaf611.zip
Make print() NUL-safe
Diffstat (limited to 'src/script')
-rw-r--r--src/script/lua_api/l_util.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/script/lua_api/l_util.cpp b/src/script/lua_api/l_util.cpp
index b30bab292..57db632c9 100644
--- a/src/script/lua_api/l_util.cpp
+++ b/src/script/lua_api/l_util.cpp
@@ -47,11 +47,12 @@ int ModApiUtil::l_debug(lua_State *L)
lua_pushvalue(L, -1); /* function to be called */
lua_pushvalue(L, i); /* value to print */
lua_call(L, 1, 1);
- const char *s = lua_tostring(L, -1);
- if (i>1)
+ size_t len;
+ const char *s = lua_tolstring(L, -1, &len);
+ if (i > 1)
dstream << "\t";
if (s)
- dstream << s;
+ dstream << std::string(s, len);
lua_pop(L, 1);
}
dstream << std::endl;