]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix leak in lua when script does not execute properly in xml_binding handler
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 22 Sep 2014 22:56:59 +0000 (03:56 +0500)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 22 Sep 2014 22:57:04 +0000 (03:57 +0500)
src/mod/languages/mod_lua/mod_lua.cpp

index 95e6adbc9f9dc56796f23a9f10cca8152d64662d..be68a43eb4bf10d48f5f1bf78b873931174a1d32 100644 (file)
@@ -236,13 +236,14 @@ static switch_xml_t lua_fetch(const char *section,
 {
 
        switch_xml_t xml = NULL;
+       char *mycmd = NULL;
 
        if (!zstr(globals.xml_handler)) {
                lua_State *L = lua_init();
-               char *mycmd = strdup(globals.xml_handler);
                const char *str;
                int error;
 
+               mycmd = strdup(globals.xml_handler);
                switch_assert(mycmd);
 
                lua_newtable(L);
@@ -267,7 +268,7 @@ static switch_xml_t lua_fetch(const char *section,
 
                if((error = lua_parse_and_execute(L, mycmd))){
                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "LUA script parse/execute error!\n");
-                   return NULL;
+                   goto end;
                }
 
                lua_getglobal(L, "XML_STRING");
@@ -285,9 +286,13 @@ static switch_xml_t lua_fetch(const char *section,
                }
 
                lua_uninit(L);
-               free(mycmd);
+
        }
 
+ end:
+
+       switch_safe_free(mycmd);
+
        return xml;
 }