From d2884ac5a6c1c3bfe2a01adba9dd5bf4178ce741 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Thu, 15 May 2014 13:58:08 +0000 Subject: [PATCH] CID:1214211 Resource leak --- src/mod/applications/mod_sms/mod_sms.c | 27 +++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/mod/applications/mod_sms/mod_sms.c b/src/mod/applications/mod_sms/mod_sms.c index 856029b7ce..cb1d3a49dc 100644 --- a/src/mod/applications/mod_sms/mod_sms.c +++ b/src/mod/applications/mod_sms/mod_sms.c @@ -501,18 +501,23 @@ SWITCH_STANDARD_CHAT_APP(set_function) { char *var, *val; - if (data) { - var = strdup(data); - if ((val = strchr(var, '='))) { - *val++ = '\0'; - } - - if (zstr(val)) { - switch_event_del_header(message, var); - } else { - switch_event_add_header_string(message, SWITCH_STACK_BOTTOM, var, val); - } + if (!data) return SWITCH_STATUS_SUCCESS; + + var = strdup(data); + + if (!var) return SWITCH_STATUS_SUCCESS; + + if ((val = strchr(var, '='))) { + *val++ = '\0'; } + + 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; }