[Asterisk-code-review] cdr radius,cel radius: Fix old memleak in unload (asterisk[master])

Anonymous Coward asteriskteam at digium.com
Wed Oct 26 11:13:43 CDT 2016


Anonymous Coward #1000019 has submitted this change and it was merged. ( https://gerrit.asterisk.org/4059 )

Change subject: cdr_radius,cel_radius: Fix old memleak in unload
......................................................................


cdr_radius,cel_radius: Fix old memleak in unload

- Call "rc_openlog" optional. If you do not call,
you will simply NULL instead of a name.

- On the one PID can be only one syslog channel.
And it can already be run in logger.c

- Calling rc_openlog we assigns a new name for
the channel syslog. This unexpected behavior for logger.c.

Most lesser evil, is to agree on a NULL name syslog
if the channel was not launched in logger.c.

It also solves the problem of memory leaks.

ASTERISK-26455 #close

Change-Id: Ic17c38de67583e971d78fe18807d1a9faf8f0afd
---
M CHANGES
M cdr/cdr_radius.c
M cel/cel_radius.c
3 files changed, 10 insertions(+), 24 deletions(-)

Approvals:
  George Joseph: Looks good to me, approved
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, but someone else must approve
  Badalian Vyacheslav: Looks good to me, but someone else must approve



diff --git a/CHANGES b/CHANGES
index 622973c..5948360 100644
--- a/CHANGES
+++ b/CHANGES
@@ -34,6 +34,16 @@
    preferred codec rather than advertising all joint codec capabilities.
    This limits the other side's codec choice to exactly what we prefer.
 
+cdr_radius
+------------------
+ * To fix a memory leak the syslog channel is now empty if it has not been set
+   and used by a syslog channel in the logger.
+
+cel_radius
+------------------
+ * To fix a memory leak the syslog channel is now empty if it has not been set
+   and used by a syslog channel in the logger.
+
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 14.1.0 to Asterisk 14.2.0 ----------
 ------------------------------------------------------------------------------
diff --git a/cdr/cdr_radius.c b/cdr/cdr_radius.c
index e1a639c..ddde5b8 100644
--- a/cdr/cdr_radius.c
+++ b/cdr/cdr_radius.c
@@ -265,18 +265,6 @@
 	} else
 		return AST_MODULE_LOAD_DECLINE;
 
-	/*
-	 * start logging
-	 *
-	 * NOTE: Yes this causes a slight memory leak if the module is
-	 * unloaded.  However, it is better than a crash if cdr_radius
-	 * and cel_radius are both loaded.
-	 */
-	tmp = ast_strdup("asterisk");
-	if (tmp) {
-		rc_openlog((char *) tmp);
-	}
-
 	/* read radiusclient-ng config file */
 	if (!(rh = rc_read_config(radiuscfg))) {
 		ast_log(LOG_NOTICE, "Cannot load radiusclient-ng configuration file %s.\n", radiuscfg);
diff --git a/cel/cel_radius.c b/cel/cel_radius.c
index 3c20e97..f6ab892 100644
--- a/cel/cel_radius.c
+++ b/cel/cel_radius.c
@@ -237,18 +237,6 @@
 		return AST_MODULE_LOAD_DECLINE;
 	}
 
-	/*
-	 * start logging
-	 *
-	 * NOTE: Yes this causes a slight memory leak if the module is
-	 * unloaded.  However, it is better than a crash if cdr_radius
-	 * and cel_radius are both loaded.
-	 */
-	tmp = ast_strdup("asterisk");
-	if (tmp) {
-		rc_openlog((char *) tmp);
-	}
-
 	/* read radiusclient-ng config file */
 	if (!(rh = rc_read_config(radiuscfg))) {
 		ast_log(LOG_NOTICE, "Cannot load radiusclient-ng configuration file %s.\n", radiuscfg);

-- 
To view, visit https://gerrit.asterisk.org/4059
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic17c38de67583e971d78fe18807d1a9faf8f0afd
Gerrit-PatchSet: 5
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Badalian Vyacheslav <v.badalyan at open-bs.ru>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Badalian Vyacheslav <v.badalyan at open-bs.ru>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-code-review mailing list