summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2017-01-10 17:37:38 -0600
committerRichard Mudgett <rmudgett@digium.com>2017-01-24 14:10:16 -0600
commit607b3ac736e9bdd69acb69f85c2d5a66271a4bb2 (patch)
treeb8830895a1d67f3df98f02713f152a93483dfb85
parent48178e5918967337624a7e43ff1d84a7bb63fa85 (diff)
astobj2.c: Add excessive ref count trap.
Change-Id: I32e6a589cf9009450e4ff7cb85c07c9d9ef7fe4a
-rw-r--r--main/astobj2.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/main/astobj2.c b/main/astobj2.c
index 7320c5efb..569db0b7b 100644
--- a/main/astobj2.c
+++ b/main/astobj2.c
@@ -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;
}