diff --git a/src/switch_channel.c b/src/switch_channel.c index 555132fe38..429ac735d2 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -1390,10 +1390,12 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel if (switch_api_execute(vname, vval, channel->session, &stream) == SWITCH_STATUS_SUCCESS) { func_val = stream.data; sub_val = func_val; + } else { + free(stream.data); } switch_safe_free(expanded); - free(stream.data); + } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n"); free(data);