]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix mem leak in phrases
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 3 Mar 2010 19:55:15 +0000 (19:55 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 3 Mar 2010 19:55:15 +0000 (19:55 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16884 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_ivr_play_say.c

index 19eb38f5eab609ff5416a7ab8d8fecd921391682..0b5049d1f47adbbb271aeccc3cddc294d103cc67 100644 (file)
@@ -247,8 +247,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *s
                                        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 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *s
                                                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_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *s
                                        }
 
                                        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;
                        }