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


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@417505 65c4cc65-6c06-0410-ace0-fbb531ad65f3
changes/61/61/1
Corey Farrell 11 years ago
parent fe70d27731
commit 23d1b904b0

@ -518,12 +518,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) {
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) {
@ -532,6 +528,11 @@ int __ao2_ref_debug(void *user_data, int delta, const char *tag, const char *fil
fflush(ref_log);
}
}
if (obj == NULL) {
return -1;
}
return internal_ao2_ref(user_data, delta, file, line, func);
}

Loading…
Cancel
Save