[asterisk-commits] tzafrir: trunk r308371 - /trunk/main/pbx.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Feb 21 07:58:28 CST 2011


Author: tzafrir
Date: Mon Feb 21 07:58:18 2011
New Revision: 308371

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=308371
Log:
fix a memory leak in device state

The callback handle_statechange (pbx.c) fails to release its data
pointer, leaking memory in the process.

Reported by: tzafrir
Patches:
      18735_pbx_free_callback.diff uploaded by tzafrir (license 46)

Review: https://reviewboard.asterisk.org/r/1110/


Modified:
    trunk/main/pbx.c

Modified: trunk/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/pbx.c?view=diff&rev=308371&r1=308370&r2=308371
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Mon Feb 21 07:58:18 2011
@@ -4348,9 +4348,11 @@
 	struct ao2_iterator cb_iter;
 
 	if (ao2_container_count(hintdevices) == 0) {
+		ast_free(sc);
 		return 0;
 	}
 	if (!(cmpdevice = ast_malloc(sizeof(*cmpdevice) + strlen(sc->dev)))) {
+		ast_free(sc);
 		return -1;
 	}
 	strcpy(cmpdevice->hintdevice, sc->dev);
@@ -4414,6 +4416,7 @@
 	if (cmpdevice) {
 		ast_free(cmpdevice);
 	}
+	ast_free(sc);
 	return 0;
 }
 




More information about the asterisk-commits mailing list