[svn-commits] kpfleming: trunk r225405 - /trunk/main/astobj2.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Oct 22 13:41:51 CDT 2009


Author: kpfleming
Date: Thu Oct 22 13:41:47 2009
New Revision: 225405

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=225405
Log:
Fix a refcount error introduced by yesterday's OBJ_MULTIPLE commit.

When an object is being unlinked from its container *and* being returned to
the caller, we do not want to decrement the reference count after unlinking
it from the container, as the reference that the container held is what we
are returning to the caller... and if it was the only remaining reference to
the object, that could result in the object being destroyed.


Modified:
    trunk/main/astobj2.c

Modified: trunk/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/astobj2.c?view=diff&rev=225405&r1=225404&r2=225405
==============================================================================
--- trunk/main/astobj2.c (original)
+++ trunk/main/astobj2.c Thu Oct 22 13:41:47 2009
@@ -685,7 +685,6 @@
 				match &= cb_default(EXTERNAL_OBJ(cur->astobj), arg, flags);
 			}
 
-			/* we found the object, performing operations according flags */
 			if (match == 0) {	/* no match, no stop, continue */
 				continue;
 			} else if (match == CMP_STOP) {	/* no match but stop, we are done */
@@ -693,6 +692,7 @@
 				break;
 			}
 
+			/* we found the object, performing operations according flags */
 			/* we have a match (CMP_MATCH) here */
 			if (!(flags & OBJ_NODATA)) {	/* if must return the object, record the value */
 				/* it is important to handle this case before the unlink */
@@ -719,12 +719,6 @@
 				AST_LIST_REMOVE_CURRENT(entry);
 				/* update number of elements */
 				ast_atomic_fetchadd_int(&c->elements, -1);
-				if (!(flags & OBJ_NODATA)) {
-					if (tag)
-						__ao2_ref_debug(EXTERNAL_OBJ(cur->astobj), -1, tag, file, line, funcname);
-					else
-						__ao2_ref(EXTERNAL_OBJ(cur->astobj), -1);
-				}
 				ast_free(cur);	/* free the link record */
 			}
 




More information about the svn-commits mailing list