[asterisk-commits] rmudgett: trunk r217332 - /trunk/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 8 18:38:00 CDT 2009


Author: rmudgett
Date: Tue Sep  8 18:37:57 2009
New Revision: 217332

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=217332
Log:
Fix memory leak of sig_xxx private structures.

Modified:
    trunk/channels/chan_dahdi.c
    trunk/channels/sig_analog.c
    trunk/channels/sig_analog.h
    trunk/channels/sig_pri.c
    trunk/channels/sig_pri.h

Modified: trunk/channels/chan_dahdi.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/channels/chan_dahdi.c?view=diff&rev=217332&r1=217331&r2=217332
==============================================================================
--- trunk/channels/chan_dahdi.c (original)
+++ trunk/channels/chan_dahdi.c Tue Sep  8 18:37:57 2009
@@ -4683,6 +4683,16 @@
 		p->prev->next = p->next;
 	if (p->next)
 		p->next->prev = p->prev;
+	if (p->sig_pvt) {
+		if (analog_lib_handles(p->sig, 0, 0)) {
+			analog_delete(p->sig_pvt);
+		}
+#if defined(HAVE_PRI)
+		if (dahdi_sig_pri_lib_handles(p->sig)) {
+			sig_pri_chan_delete(p->sig_pvt);
+		}
+#endif	/* defined(HAVE_PRI) */
+	}
 	if (p->use_smdi)
 		ast_smdi_interface_unref(p->smdi_iface);
 	if (p->mwi_event_sub)
@@ -10693,6 +10703,7 @@
 			} else {
 				chan_sig = 0;
 			}
+			tmp->sig = chan_sig;
 
 			if (analog_lib_handles(chan_sig, tmp->radio, tmp->oprmode)) {
 				analog_p = analog_new(dahdisig_to_analogsig(chan_sig), &dahdi_analog_callbacks, tmp);
@@ -11032,7 +11043,6 @@
 			tmp->mwimonitor_neon = conf->chan.mwimonitor_neon;
 			tmp->mwimonitor_rpas = conf->chan.mwimonitor_rpas;
 		}
-		tmp->sig = chan_sig;
 		tmp->outsigmod = conf->chan.outsigmod;
 		tmp->ringt_base = ringt_base;
 		tmp->firstradio = 0;

Modified: trunk/channels/sig_analog.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/channels/sig_analog.c?view=diff&rev=217332&r1=217331&r2=217332
==============================================================================
--- trunk/channels/sig_analog.c (original)
+++ trunk/channels/sig_analog.c Tue Sep  8 18:37:57 2009
@@ -3394,12 +3394,11 @@
 }
 
 
-struct analog_pvt * analog_new(enum analog_sigtype signallingtype, struct analog_callback *c, void *private_data)
+struct analog_pvt *analog_new(enum analog_sigtype signallingtype, struct analog_callback *c, void *private_data)
 {
 	struct analog_pvt *p;
 
 	p = ast_calloc(1, sizeof(*p));
-
 	if (!p) {
 		return p;
 	}
@@ -3418,6 +3417,19 @@
 	return p;
 }
 
+/*!
+ * \brief Delete the analog private structure.
+ * \since 1.6.3
+ *
+ * \param doomed Analog private structure to delete.
+ *
+ * \return Nothing
+ */
+void analog_delete(struct analog_pvt *doomed)
+{
+	ast_free(doomed);
+}
+
 int analog_config_complete(struct analog_pvt *p)
 {
 	/* No call waiting on non FXS channels */

Modified: trunk/channels/sig_analog.h
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/channels/sig_analog.h?view=diff&rev=217332&r1=217331&r2=217332
==============================================================================
--- trunk/channels/sig_analog.h (original)
+++ trunk/channels/sig_analog.h Tue Sep  8 18:37:57 2009
@@ -310,7 +310,8 @@
 	int ringt_base;
 };
 
-struct analog_pvt * analog_new(enum analog_sigtype signallingtype, struct analog_callback *c, void *private_data);
+struct analog_pvt *analog_new(enum analog_sigtype signallingtype, struct analog_callback *c, void *private_data);
+void analog_delete(struct analog_pvt *doomed);
 
 void analog_free(struct analog_pvt *p);
 

Modified: trunk/channels/sig_pri.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/channels/sig_pri.c?view=diff&rev=217332&r1=217331&r2=217332
==============================================================================
--- trunk/channels/sig_pri.c (original)
+++ trunk/channels/sig_pri.c Tue Sep  8 18:37:57 2009
@@ -3060,6 +3060,19 @@
 	return p;
 }
 
+/*!
+ * \brief Delete the sig_pri private channel structure.
+ * \since 1.6.3
+ *
+ * \param doomed sig_pri private channel structure to delete.
+ *
+ * \return Nothing
+ */
+void sig_pri_chan_delete(struct sig_pri_chan *doomed)
+{
+	ast_free(doomed);
+}
+
 static void build_status(char *s, size_t len, int status, int active)
 {
 	if (!s || len < 1) {

Modified: trunk/channels/sig_pri.h
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/channels/sig_pri.h?view=diff&rev=217332&r1=217331&r2=217332
==============================================================================
--- trunk/channels/sig_pri.h (original)
+++ trunk/channels/sig_pri.h Tue Sep  8 18:37:57 2009
@@ -251,6 +251,7 @@
 struct ast_channel *sig_pri_request(struct sig_pri_chan *p, enum sig_pri_law law, const struct ast_channel *requestor);
 
 struct sig_pri_chan *sig_pri_chan_new(void *pvt_data, struct sig_pri_callback *callback, struct sig_pri_pri *pri, int logicalspan, int channo, int trunkgroup);
+void sig_pri_chan_delete(struct sig_pri_chan *doomed);
 
 int pri_is_up(struct sig_pri_pri *pri);
 




More information about the asterisk-commits mailing list