[asterisk-commits] mjordan: trunk r396915 - /trunk/main/data.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Aug 18 16:26:40 CDT 2013


Author: mjordan
Date: Sun Aug 18 16:26:37 2013
New Revision: 396915

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=396915
Log:
Fix invalid access to disposed memory in main/data unit test

It is not safe to iterate over a macro'd list of ao2 objects, deref them such
that the item's destructor is called, and leave them in the list. The list
macro to iterate over items requires the item to be a valid allocated object
in order to proceed to the next item; with MALLOC_DEBUG on the corruption of
the linked list is caught in the crash.

This patch fixes the invalid access to free'd memory by removing the ao2 item
from the list before de-refing it.

Modified:
    trunk/main/data.c

Modified: trunk/main/data.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/data.c?view=diff&rev=396915&r1=396914&r2=396915
==============================================================================
--- trunk/main/data.c (original)
+++ trunk/main/data.c Sun Aug 18 16:26:37 2013
@@ -1631,7 +1631,7 @@
 {
 	struct data_filter *filter = obj, *globres;
 
-	AST_LIST_TRAVERSE(&(filter->glob_list), globres, list) {
+	while ((globres = AST_LIST_REMOVE_HEAD(&(filter->glob_list), list))) {
 		ao2_ref(globres, -1);
 	}
 




More information about the asterisk-commits mailing list