From: Richard Mudgett Date: Wed, 1 Jun 2016 18:57:53 +0000 (-0500) Subject: logging,cdr,cel: Fix stringfield memory leak. X-Git-Tag: 13.10.0-rc1~52^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fchanges%2F27%2F2927%2F1;p=thirdparty%2Fasterisk.git logging,cdr,cel: Fix stringfield memory leak. The stringfields refactor to allow adding stringfields to the end of a structure (f6f4cf459f43f072604927209b39646f84aaa2e2) exposed some incomplete cleanup code by some stringfield users. The most noticeable leaker is the logging system where there is a leak for every log message generated. ASTERISK-26078 #close Reported by: Etienne Lessard Patches: jira_asterisk_26078_v13.patch (license #5621) patch uploaded by Richard Mudgett Change-Id: If6a08b31336b492c3de6f9dfd07c447f8d5a8782 --- diff --git a/cdr/cdr_custom.c b/cdr/cdr_custom.c index df763639fa..6ef2cb094e 100644 --- a/cdr/cdr_custom.c +++ b/cdr/cdr_custom.c @@ -81,8 +81,10 @@ static AST_RWLIST_HEAD_STATIC(sinks, cdr_custom_config); static void free_config(void) { struct cdr_custom_config *sink; + while ((sink = AST_RWLIST_REMOVE_HEAD(&sinks, list))) { ast_mutex_destroy(&sink->lock); + ast_string_field_free_memory(sink); ast_free(sink); } } diff --git a/cdr/cdr_syslog.c b/cdr/cdr_syslog.c index 458721aa83..c1169a35c5 100644 --- a/cdr/cdr_syslog.c +++ b/cdr/cdr_syslog.c @@ -76,8 +76,10 @@ static AST_RWLIST_HEAD_STATIC(sinks, cdr_syslog_config); static void free_config(void) { struct cdr_syslog_config *sink; + while ((sink = AST_RWLIST_REMOVE_HEAD(&sinks, list))) { ast_mutex_destroy(&sink->lock); + ast_string_field_free_memory(sink); ast_free(sink); } } diff --git a/cel/cel_custom.c b/cel/cel_custom.c index edb009686e..0b2ac764f7 100644 --- a/cel/cel_custom.c +++ b/cel/cel_custom.c @@ -71,8 +71,10 @@ static AST_RWLIST_HEAD_STATIC(sinks, cel_config); static void free_config(void) { struct cel_config *sink; + while ((sink = AST_RWLIST_REMOVE_HEAD(&sinks, list))) { ast_mutex_destroy(&sink->lock); + ast_string_field_free_memory(sink); ast_free(sink); } } diff --git a/main/logger.c b/main/logger.c index 9f03b4efa3..a70b6d15eb 100644 --- a/main/logger.c +++ b/main/logger.c @@ -168,6 +168,7 @@ static void logmsg_free(struct logmsg *msg) if (msg->callid) { ast_callid_unref(msg->callid); } + ast_string_field_free_memory(msg); ast_free(msg); }