CID:1214211 Resource leak

This commit is contained in:
Michael Jerris 2014-05-15 13:58:08 +00:00
parent 0469db0305
commit d2884ac5a6
1 changed files with 16 additions and 11 deletions

View File

@ -501,18 +501,23 @@ SWITCH_STANDARD_CHAT_APP(set_function)
{ {
char *var, *val; char *var, *val;
if (data) { if (!data) return SWITCH_STATUS_SUCCESS;
var = strdup(data);
if ((val = strchr(var, '='))) { var = strdup(data);
*val++ = '\0';
} if (!var) return SWITCH_STATUS_SUCCESS;
if (zstr(val)) { if ((val = strchr(var, '='))) {
switch_event_del_header(message, var); *val++ = '\0';
} else {
switch_event_add_header_string(message, SWITCH_STACK_BOTTOM, var, val);
}
} }
if (zstr(val)) {
switch_event_del_header(message, var);
} else {
switch_event_add_header_string(message, SWITCH_STACK_BOTTOM, var, val);
}
free(var);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }