mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-18 01:28:42 +00:00
fix leak in lua when script does not execute properly in xml_binding handler
This commit is contained in:
parent
4dc7f92aff
commit
1bb0b8e16d
@ -236,13 +236,14 @@ static switch_xml_t lua_fetch(const char *section,
|
|||||||
{
|
{
|
||||||
|
|
||||||
switch_xml_t xml = NULL;
|
switch_xml_t xml = NULL;
|
||||||
|
char *mycmd = NULL;
|
||||||
|
|
||||||
if (!zstr(globals.xml_handler)) {
|
if (!zstr(globals.xml_handler)) {
|
||||||
lua_State *L = lua_init();
|
lua_State *L = lua_init();
|
||||||
char *mycmd = strdup(globals.xml_handler);
|
|
||||||
const char *str;
|
const char *str;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
mycmd = strdup(globals.xml_handler);
|
||||||
switch_assert(mycmd);
|
switch_assert(mycmd);
|
||||||
|
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
@ -267,7 +268,7 @@ static switch_xml_t lua_fetch(const char *section,
|
|||||||
|
|
||||||
if((error = lua_parse_and_execute(L, mycmd))){
|
if((error = lua_parse_and_execute(L, mycmd))){
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "LUA script parse/execute error!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "LUA script parse/execute error!\n");
|
||||||
return NULL;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_getglobal(L, "XML_STRING");
|
lua_getglobal(L, "XML_STRING");
|
||||||
@ -285,9 +286,13 @@ static switch_xml_t lua_fetch(const char *section,
|
|||||||
}
|
}
|
||||||
|
|
||||||
lua_uninit(L);
|
lua_uninit(L);
|
||||||
free(mycmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end:
|
||||||
|
|
||||||
|
switch_safe_free(mycmd);
|
||||||
|
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user