[asterisk-commits] mmichelson: trunk r141995 - /trunk/channels/chan_oss.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 9 05:20:58 CDT 2008


Author: mmichelson
Date: Tue Sep  9 05:20:58 2008
New Revision: 141995

URL: http://svn.digium.com/view/asterisk?view=rev&rev=141995
Log:
Fix a memory leak in chan_oss

(closes issue #13311)
Reported by: eliel
Patches:
      chan_oss.c.patch uploaded by eliel (license 64)


Modified:
    trunk/channels/chan_oss.c

Modified: trunk/channels/chan_oss.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_oss.c?view=diff&rev=141995&r1=141994&r2=141995
==============================================================================
--- trunk/channels/chan_oss.c (original)
+++ trunk/channels/chan_oss.c Tue Sep  9 05:20:58 2008
@@ -1464,18 +1464,22 @@
 
 static int unload_module(void)
 {
-	struct chan_oss_pvt *o;
+	struct chan_oss_pvt *o, *next;
 
 	ast_channel_unregister(&oss_tech);
 	ast_cli_unregister_multiple(cli_oss, sizeof(cli_oss) / sizeof(struct ast_cli_entry));
 
-	for (o = oss_default.next; o; o = o->next) {
+	o = oss_default.next;
+	while (o) {
 		close(o->sounddev);
 		if (o->owner)
 			ast_softhangup(o->owner, AST_SOFTHANGUP_APPUNLOAD);
 		if (o->owner)			/* XXX how ??? */
 			return -1;
-		/* XXX what about the memory allocated ? */
+		next = o->next;
+		ast_free(o->name);
+		ast_free(o);
+		o = next;
 	}
 	return 0;
 }




More information about the asterisk-commits mailing list