Revision
16884
Author
anthm
Date
2010-03-03 13:55:15 -0600 (Wed, 03 Mar 2010)

Log Message

fix mem leak in phrases

Modified Paths

Diff

Modified: freeswitch/trunk/src/switch_ivr_play_say.c (16883 => 16884)


--- freeswitch/trunk/src/switch_ivr_play_say.c	2010-03-03 19:04:10 UTC (rev 16883)
+++ freeswitch/trunk/src/switch_ivr_play_say.c	2010-03-03 19:55:15 UTC (rev 16884)
@@ -247,8 +247,8 @@
 					char *adata = (char *) switch_xml_attr_soft(action, "data");
 					char *func = (char *) switch_xml_attr_soft(action, "function");
 
-					if (strchr(pattern, '(') && strchr(adata, '$')) {
-						len = (uint32_t) (strlen(data) + strlen(adata) + 10) * (proceed ? proceed : 1);
+					if (strchr(pattern, '(') && strchr(adata, '$') && proceed > 0) {
+						len = (uint32_t) (strlen(data) + strlen(adata) + 10) * proceed;
 						if (!(substituted = malloc(len))) {
 							switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Memory Error!\n");
 							switch_regex_safe_free(re);
@@ -287,12 +287,6 @@
 						status = SWITCH_STATUS_FALSE;
 
 						cmd = switch_core_session_strdup(session, odata);
-
-						if (!cmd) {
-							switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Allocation error calling execute\n");
-							break;
-						}
-
 						cmd_args = switch_separate_paren_args(cmd);
 
 						if (!cmd_args) {
@@ -336,14 +330,14 @@
 					}
 
 					switch_ivr_sleep(session, pause, SWITCH_FALSE, NULL);
+					switch_safe_free(expanded);
+					switch_safe_free(substituted);
+					
 				}
 			}
 
 			switch_regex_safe_free(re);
-			switch_safe_free(expanded);
-			switch_safe_free(substituted);
-
-
+			
 			if ((match && do_break && switch_true(do_break)) || status == SWITCH_STATUS_BREAK) {
 				break;
 			}