]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-5838 fix segfaults in unload of mod_format_cdr
authorNathan Neulinger <nneul@neulinger.org>
Wed, 2 Oct 2013 21:42:49 +0000 (16:42 -0500)
committerNathan Neulinger <nneul@neulinger.org>
Wed, 2 Oct 2013 21:42:49 +0000 (16:42 -0500)
src/mod/event_handlers/mod_format_cdr/mod_format_cdr.c

index 79edc203e2626c5a0aa18b4833f5a4e915a1fa40..6b3ee46fc08206a612f6260bfd061df42168256c 100644 (file)
@@ -557,6 +557,8 @@ switch_status_t mod_format_cdr_load_profile_xml(switch_xml_t xprofile)
        }
 
        profile = switch_core_alloc(pool, sizeof(cdr_profile_t));
+       memset(profile, 0, sizeof(cdr_profile_t));
+
        profile->pool = pool;
        profile->name = switch_core_strdup(profile->pool, profile_name);
 
@@ -768,9 +770,9 @@ void mod_format_cdr_profile_shutdown(cdr_profile_t *profile)
 
        switch_safe_free(profile->log_dir);
        
-       switch_core_destroy_memory_pool(&profile->pool);
-
        switch_thread_rwlock_destroy(profile->log_path_lock);
+
+       switch_core_destroy_memory_pool(&profile->pool);
 }
 
 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_format_cdr_shutdown)
@@ -788,13 +790,12 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_format_cdr_shutdown)
                switch_hash_this(hi, NULL, NULL, &val);
                profile = (cdr_profile_t *) val;
 
-               mod_format_cdr_profile_shutdown(profile);
+               if ( profile ) {
+                       mod_format_cdr_profile_shutdown(profile);
+               }
        }
 
        switch_core_hash_destroy(&globals.profile_hash);
-       switch_core_destroy_memory_pool(&globals.pool);
-
-       memset(&globals, 0, sizeof(globals));
 
        return SWITCH_STATUS_SUCCESS;
 }