From bcbb8324db4be0cf537aecc1eef10916a66ad7ba Mon Sep 17 00:00:00 2001 From: Matthew Jordan Date: Sun, 18 Aug 2013 21:26:37 +0000 Subject: 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. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396915 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main') diff --git a/main/data.c b/main/data.c index 4c39362f5..73a336613 100644 --- a/main/data.c +++ b/main/data.c @@ -1631,7 +1631,7 @@ static void data_filter_destructor(void *obj) { 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); } -- cgit v1.2.3