summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2013-08-18 21:26:37 +0000
committerMatthew Jordan <mjordan@digium.com>2013-08-18 21:26:37 +0000
commitbcbb8324db4be0cf537aecc1eef10916a66ad7ba (patch)
tree040f866ed8ffd9ceb5310f237b37e50c3b979c20
parent124f45a6252f7ec0596d034ea714269813332e40 (diff)
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
-rw-r--r--main/data.c2
1 files changed, 1 insertions, 1 deletions
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);
}