[asterisk-commits] rmudgett: branch 1.8 r379963 - /branches/1.8/main/astobj2.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 22 18:19:43 CST 2013


Author: rmudgett
Date: Tue Jan 22 18:19:40 2013
New Revision: 379963

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=379963
Log:
Attempt to be more helpful when using a bad ao2 object pointer.

Backport of -r360626 with some enhancements.  Put the external obj pointer
in the message instead of the internal version.

Modified:
    branches/1.8/main/astobj2.c

Modified: branches/1.8/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/astobj2.c?view=diff&rev=379963&r1=379962&r2=379963
==============================================================================
--- branches/1.8/main/astobj2.c (original)
+++ branches/1.8/main/astobj2.c Tue Jan 22 18:19:40 2013
@@ -117,9 +117,16 @@
 	}
 
 	p = (struct astobj2 *) ((char *) user_data - sizeof(*p));
-	if (AO2_MAGIC != (p->priv_data.magic) ) {
-		ast_log(LOG_ERROR, "bad magic number 0x%x for %p\n", p->priv_data.magic, p);
-		p = NULL;
+	if (AO2_MAGIC != p->priv_data.magic) {
+		if (p->priv_data.magic) {
+			ast_log(LOG_ERROR, "bad magic number 0x%x for object %p\n",
+				p->priv_data.magic, user_data);
+		} else {
+			ast_log(LOG_ERROR,
+				"bad magic number for object %p. Object is likely destroyed.\n",
+				user_data);
+		}
+		return NULL;
 	}
 
 	return p;




More information about the asterisk-commits mailing list