aboutsummaryrefslogtreecommitdiff
path: root/src/script/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/common')
-rw-r--r--src/script/common/c_converter.cpp4
-rw-r--r--src/script/common/c_converter.h2
-rw-r--r--src/script/common/helper.cpp5
3 files changed, 6 insertions, 5 deletions
diff --git a/src/script/common/c_converter.cpp b/src/script/common/c_converter.cpp
index dfd3f5cea..b9d6f0494 100644
--- a/src/script/common/c_converter.cpp
+++ b/src/script/common/c_converter.cpp
@@ -540,9 +540,9 @@ v3s16 getv3s16field_default(lua_State *L, int table,
}
void setstringfield(lua_State *L, int table,
- const char *fieldname, const char *value)
+ const char *fieldname, const std::string &value)
{
- lua_pushstring(L, value);
+ lua_pushlstring(L, value.c_str(), value.length());
if(table < 0)
table -= 1;
lua_setfield(L, table, fieldname);
diff --git a/src/script/common/c_converter.h b/src/script/common/c_converter.h
index 87bc35ac6..f84494c8d 100644
--- a/src/script/common/c_converter.h
+++ b/src/script/common/c_converter.h
@@ -91,7 +91,7 @@ std::string checkstringfield(lua_State *L, int table,
const char *fieldname);
void setstringfield(lua_State *L, int table,
- const char *fieldname, const char *value);
+ const char *fieldname, const std::string &value);
void setintfield(lua_State *L, int table,
const char *fieldname, int value);
void setfloatfield(lua_State *L, int table,
diff --git a/src/script/common/helper.cpp b/src/script/common/helper.cpp
index 59bde57ab..f53a2b7e8 100644
--- a/src/script/common/helper.cpp
+++ b/src/script/common/helper.cpp
@@ -107,9 +107,10 @@ template <> v2f LuaHelper::readParam(lua_State *L, int index)
template <> std::string LuaHelper::readParam(lua_State *L, int index)
{
+ size_t length;
std::string result;
- const char *str = luaL_checkstring(L, index);
- result.append(str);
+ const char *str = luaL_checklstring(L, index, &length);
+ result.assign(str, length);
return result;
}