]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-10240: [freeswitch-core] Use the "Negative Lookahead" in xml dialplan cause memory...
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 5 Jun 2017 23:15:18 +0000 (18:15 -0500)
committerMike Jerris <mike@jerris.com>
Tue, 6 Jun 2017 14:40:16 +0000 (09:40 -0500)
Conflicts:
src/switch_channel.c

src/switch_channel.c
src/switch_regex.c

index 2b4af66dab83b32b6fe4dbbf706c4a17ad94748d..9111224a0bdc00cc25130332988e13831f2f8350 100644 (file)
@@ -4392,15 +4392,17 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_timestamps(switch_channel_t *
                                X = malloc(len);
                                
                                for (i = 0; i < proceed; i++) {
-                                       if (pcre_get_substring(dtstr, ovector, proceed, i, &replace) > 0) {
-                                               switch_size_t plen = strlen(replace);
-                                               memset(X, 'X', plen);
-                                               *(X+plen) = '\0';
-
-                                               switch_safe_free(substituted);
-                                               substituted = switch_string_replace(substituted ? substituted : dtstr, replace, X);
-                                               
-                                               pcre_free_substring(replace);
+                                       if (pcre_get_substring(dtstr, ovector, proceed, i, &replace) >= 0) {
+                                               if (replace) {
+                                                       switch_size_t plen = strlen(replace);
+                                                       memset(X, 'X', plen);
+                                                       *(X+plen) = '\0';
+                                                       
+                                                       switch_safe_free(substituted);
+                                                       substituted = switch_string_replace(substituted ? substituted : dtstr, replace, X);
+                                                       
+                                                       pcre_free_substring(replace);
+                                               }
                                        }
                                }
                                
index 2f6b969fc84c771e92d1753b05de82327eeb1fe6..0531491aafc6989690e6f040a0872d357a294e29 100644 (file)
@@ -174,12 +174,15 @@ SWITCH_DECLARE(void) switch_perform_substitution(switch_regex_t *re, int match_c
                                num = -1;
                        }
 
-                       if (pcre_get_substring(field_data, ovector, match_count, num, &replace) > 0) {
-                               switch_size_t r;
-                               for (r = 0; r < strlen(replace) && y < (len - 1); r++) {
-                                       substituted[y++] = replace[r];
+                       if (pcre_get_substring(field_data, ovector, match_count, num, &replace) >= 0) {
+                               if (replace) {
+                                       switch_size_t r;
+
+                                       for (r = 0; r < strlen(replace) && y < (len - 1); r++) {
+                                               substituted[y++] = replace[r];
+                                       }
+                                       pcre_free_substring(replace);
                                }
-                               pcre_free_substring(replace);
                        }
                } else {
                        substituted[y++] = data[x];
@@ -200,9 +203,11 @@ SWITCH_DECLARE(void) switch_capture_regex(switch_regex_t *re, int match_count, c
        int i;
 
        for (i = 0; i < match_count; i++) {
-               if (pcre_get_substring(field_data, ovector, match_count, i, &replace) > 0) {
-                       callback(var, replace, user_data);
-                       pcre_free_substring(replace);
+               if (pcre_get_substring(field_data, ovector, match_count, i, &replace) >= 0) {
+                       if (replace) {
+                               callback(var, replace, user_data);
+                               pcre_free_substring(replace);
+                       }
                }
        }
 }