[svn-commits] coreyfarrell: branch 1.8 r417500 - /branches/1.8/main/astobj2.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jun 27 14:24:28 CDT 2014


Author: coreyfarrell
Date: Fri Jun 27 14:24:20 2014
New Revision: 417500

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=417500
Log:
Ensure REF_DEBUG records entrys for attempts to ao2_ref an invalid object

This change ensures that __ao2_ref_debug writes to ref_log when given a
non-NULL pointer to an invalid ao2 object.  This is to ensure that we
record any attempt manipulate references of already freed objects.

ASTERISK-23948 #close
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/3677/

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=417500&r1=417499&r2=417500
==============================================================================
--- branches/1.8/main/astobj2.c (original)
+++ branches/1.8/main/astobj2.c Fri Jun 27 14:24:20 2014
@@ -220,12 +220,8 @@
 {
 	struct astobj2 *obj = INTERNAL_OBJ(user_data);
 
-	if (obj == NULL) {
-		return -1;
-	}
-
-	if (ref_log) {
-		if (obj->priv_data.ref_counter + delta == 0) {
+	if (ref_log && user_data) {
+		if (obj && obj->priv_data.ref_counter + delta == 0) {
 			fprintf(ref_log, "%p,%d,%d,%s,%d,%s,**destructor**,%s\n", user_data, delta, ast_get_tid(), file, line, funcname, tag);
 			fflush(ref_log);
 		} else if (delta != 0) {
@@ -234,6 +230,11 @@
 			fflush(ref_log);
 		}
 	}
+
+	if (obj == NULL) {
+		return -1;
+	}
+
 	return internal_ao2_ref(user_data, delta);
 }
 




More information about the svn-commits mailing list