Attempt to be more helpful when using a bad ao2 object pointer.
authorRichard Mudgett <rmudgett@digium.com>
Tue, 27 Mar 2012 17:00:13 +0000 (17:00 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Tue, 27 Mar 2012 17:00:13 +0000 (17:00 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@360626 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/astobj2.c

index d0643fe..32758cf 100644 (file)
@@ -142,8 +142,13 @@ static inline struct astobj2 *INTERNAL_OBJ(void *user_data)
        }
 
        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);
+       if (AO2_MAGIC != p->priv_data.magic) {
+               if (p->priv_data.magic) {
+                       ast_log(LOG_ERROR, "bad magic number 0x%x for %p\n", p->priv_data.magic, p);
+               } else {
+                       ast_log(LOG_ERROR,
+                               "bad magic number for %p. Object is likely destroyed.\n", p);
+               }
                return NULL;
        }