]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
astobj2.c: Add excessive ref count trap. 01/4801/1
authorRichard Mudgett <rmudgett@digium.com>
Tue, 10 Jan 2017 23:37:38 +0000 (17:37 -0600)
committerRichard Mudgett <rmudgett@digium.com>
Tue, 24 Jan 2017 20:10:16 +0000 (14:10 -0600)
Change-Id: I32e6a589cf9009450e4ff7cb85c07c9d9ef7fe4a

main/astobj2.c

index 7320c5efbd6c0f8c87e9043751b80e856e7017d8..569db0b7b592893fc74a7e31752f9cf15e24141a 100644 (file)
@@ -421,6 +421,19 @@ static int internal_ao2_ref(void *user_data, int delta, const char *file, int li
 
        if (0 < current_value) {
                /* The object still lives. */
+#define EXCESSIVE_REF_COUNT            100000
+
+               if (EXCESSIVE_REF_COUNT <= current_value && ret < EXCESSIVE_REF_COUNT) {
+                       char excessive_ref_buf[100];
+
+                       /* We just reached or went over the excessive ref count trigger */
+                       snprintf(excessive_ref_buf, sizeof(excessive_ref_buf),
+                               "Excessive refcount %d reached on ao2 object %p",
+                               current_value, user_data);
+                       ast_log(__LOG_ERROR, file, line, func, "%s\n", excessive_ref_buf);
+
+                       __ast_assert_failed(0, excessive_ref_buf, file, line, func);
+               }
                return ret;
        }