]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
don't use memory after free when using naptr with mod_enum with multiple routes
authorBrian West <brian@freeswitch.org>
Mon, 28 Apr 2014 18:03:09 +0000 (13:03 -0500)
committerBrian West <brian@freeswitch.org>
Mon, 28 Apr 2014 18:03:09 +0000 (13:03 -0500)
src/mod/applications/mod_enum/mod_enum.c

index 3e1ae683fc715b1d41a6b92b6d99e45df7e5b9c7..d7cc9e5156220295d028deaa53425888791efda2 100644 (file)
@@ -368,7 +368,7 @@ static void parse_naptr(const ldns_rr *naptr, const char *number, enum_record_t
                int proceed = 0, ovector[30];
                char *substituted = NULL;
                char *substituted_2 = NULL;
-               char *uri;
+               char *orig_uri;
                char *uri_expanded = NULL;
                enum_route_t *route;
                int supported = 0;
@@ -385,13 +385,15 @@ static void parse_naptr(const ldns_rr *naptr, const char *number, enum_record_t
                                memset(substituted, 0, len);
 
                                switch_perform_substitution(re, proceed, replace, number, substituted, len, ovector);
-                               uri = substituted;
+                               orig_uri = substituted;
                        } else {
-                               uri = replace;
+                               orig_uri = replace;
                        }
                        
                        switch_mutex_lock(MUTEX);
                        for (route = globals.route_order; route; route = route->next) {
+                               char *uri = orig_uri;
+                               
                                if (strcasecmp(service, route->service)) {
                                        continue;
                                }
@@ -437,7 +439,7 @@ static void parse_naptr(const ldns_rr *naptr, const char *number, enum_record_t
                        switch_mutex_unlock(MUTEX);                     
 
                        if (!supported) {
-                               add_result(results, order, preference, service, uri, 0);
+                               add_result(results, order, preference, service, orig_uri, 0);
                        }
 
                        switch_safe_free(substituted);