summaryrefslogtreecommitdiff
path: root/main/astobj2.c
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2014-06-27 19:27:59 +0000
committerCorey Farrell <git@cfware.com>2014-06-27 19:27:59 +0000
commit024316fa3a2725a8a04f4bd38e292b658e67f9b8 (patch)
tree9f76f2e5d9f3caa2b5abc7af147b0286f42cdb21 /main/astobj2.c
parent9a495107b86b80a4bd804b2ddd7c4d7997ee6a3c (diff)
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/ ........ Merged revisions 417500 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 417505 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 417509 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@417511 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/astobj2.c')
-rw-r--r--main/astobj2.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/main/astobj2.c b/main/astobj2.c
index da113b118..678517bf6 100644
--- a/main/astobj2.c
+++ b/main/astobj2.c
@@ -499,14 +499,8 @@ int __ao2_ref_debug(void *user_data, int delta, const char *tag, const char *fil
{
struct astobj2 *obj = INTERNAL_OBJ(user_data);
- if (obj == NULL) {
- ast_log_backtrace();
- ast_assert(0);
- 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, func, tag);
fflush(ref_log);
} else if (delta != 0) {
@@ -515,6 +509,13 @@ int __ao2_ref_debug(void *user_data, int delta, const char *tag, const char *fil
fflush(ref_log);
}
}
+
+ if (obj == NULL) {
+ ast_log_backtrace();
+ ast_assert(0);
+ return -1;
+ }
+
return internal_ao2_ref(user_data, delta, file, line, func);
}