summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2012-01-22 18:48:44 +0800
committerErik Schilling <ablu.erikschilling@googlemail.com>2012-01-25 02:42:43 +0800
commit0ef8ff7af3e260576a066f27b24dc79ea8515e72 (patch)
tree1adccfa8219b7302e01b2601a25d6c7189cdf2f0 /src
parent5636dccf2166ef86731ca68a2ced822cf733b938 (diff)
downloadmanaserv-0ef8ff7af3e260576a066f27b24dc79ea8515e72.tar.gz
manaserv-0ef8ff7af3e260576a066f27b24dc79ea8515e72.tar.bz2
manaserv-0ef8ff7af3e260576a066f27b24dc79ea8515e72.tar.xz
manaserv-0ef8ff7af3e260576a066f27b24dc79ea8515e72.zip
Fixed use of checkstring method in the script functions
luaL_checkstring might not return so the destructor of string will not be called. Reviewed-by: Bjorn.
Diffstat (limited to 'src')
-rw-r--r--src/scripting/lua.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index a03bc574..eb50f168 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -80,7 +80,7 @@ static int npc_message(lua_State *s)
}
MessageOut msg(GPMSG_NPC_MESSAGE);
msg.writeInt16(p->getPublicID());
- msg.writeString(std::string(m), l);
+ msg.writeString(m, l);
gameHandler->sendTo(q, msg);
return 0;
}
@@ -2464,9 +2464,11 @@ static int get_distance(lua_State *s)
static int map_get_objects(lua_State *s)
{
const bool filtered = (lua_gettop(s) == 1);
- std::string filter;
+ const char *filter;
if (filtered)
+ {
filter = luaL_checkstring(s, 1);
+ }
lua_pushlightuserdata(s, (void *)&registryKey);
lua_gettable(s, LUA_REGISTRYINDEX);
@@ -2497,7 +2499,7 @@ static int map_get_objects(lua_State *s)
*/
static int map_object_get_property(lua_State *s)
{
- std::string key = luaL_checkstring(s, 2);
+ const char *key = luaL_checkstring(s, 2);
if (!lua_islightuserdata(s, 1))
{
raiseScriptError(s, "map_object_get_property called with invalid"
@@ -2602,7 +2604,8 @@ static int announce(lua_State *s)
static int require_loader(lua_State *s)
{
// Add .lua extension (maybe only do this when it doesn't have it already)
- std::string filename = luaL_checkstring(s, 1);
+ const char *file = luaL_checkstring(s, 1);
+ std::string filename = file;
filename.append(".lua");
const std::string path = ResourceManager::resolve(filename);