From 8bf0791932c8809fe5bd85d53859b8ce6197e4ed Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Sat, 16 Jan 2010 16:42:36 +0100 Subject: Prevented segmentation fault when calling the lua set_quest_var function with an illegal character handle. --- src/scripting/lua.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/scripting/lua.cpp') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 3b33a3d1..5813836e 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -925,11 +925,16 @@ static int chr_set_quest(lua_State *s) Character *q = getCharacter(s, 1); const char *m = lua_tostring(s, 2); const char *n = lua_tostring(s, 3); - if (!m || !n || m[0] == 0) + if (!m || !n || m[0] == 0 || strlen(m) == 0) { raiseScriptError(s, "chr_set_quest called with incorrect parameters."); return 0; } + if (!q) + { + raiseScriptError(s, "chr_set_quest called for nonexistent character."); + return 0; + } setQuestVar(q, m, n); return 0; } -- cgit v1.2.3-70-g09d2