[Asterisk-code-review] pjproject: Improve MALLOC DEBUG checking. (asterisk[master])

Richard Mudgett asteriskteam at digium.com
Mon Feb 19 12:41:20 CST 2018


Richard Mudgett has uploaded this change for review. ( https://gerrit.asterisk.org/8288


Change subject: pjproject: Improve MALLOC_DEBUG checking.
......................................................................

pjproject: Improve MALLOC_DEBUG checking.

Disable pjproject pool caching when MALLOC_DEBUG is enabled to catch use
after free of the pool control structs as well as the struct that created
the pool.

Change-Id: I64d5befbaeed2532f93aa027a51eb52347d2b828
---
A third-party/pjproject/patches/0000-malloc_debug.patch
1 file changed, 28 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/88/8288/1

diff --git a/third-party/pjproject/patches/0000-malloc_debug.patch b/third-party/pjproject/patches/0000-malloc_debug.patch
new file mode 100644
index 0000000..d4d37ec
--- /dev/null
+++ b/third-party/pjproject/patches/0000-malloc_debug.patch
@@ -0,0 +1,28 @@
+diff --git a/pjlib/src/pj/pool_caching.c b/pjlib/src/pj/pool_caching.c
+index 8e2c992..4c89cd9 100644
+--- a/pjlib/src/pj/pool_caching.c
++++ b/pjlib/src/pj/pool_caching.c
+@@ -226,6 +226,15 @@ static void cpool_release_pool( pj_pool_factory *pf, pj_pool_t *pool)
+     /* Decrement used count. */
+     --cp->used_count;
+ 
++#if defined(MALLOC_DEBUG)
++    /*
++     * Disable caching pools when MALLOC_DEBUG is enabled to
++     * better catch memory mis-management.
++     */
++    pj_pool_destroy_int(pool);
++
++#else
++
+     pool_capacity = pj_pool_get_capacity(pool);
+ 
+     /* Destroy the pool if the size is greater than our size or if the total
+@@ -263,6 +272,7 @@ static void cpool_release_pool( pj_pool_factory *pf, pj_pool_t *pool)
+ 
+     pj_list_insert_after(&cp->free_list[i], pool);
+     cp->capacity += pool_capacity;
++#endif
+ 
+     pj_lock_release(cp->lock);
+ }

-- 
To view, visit https://gerrit.asterisk.org/8288
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I64d5befbaeed2532f93aa027a51eb52347d2b828
Gerrit-Change-Number: 8288
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180219/0996af08/attachment.html>


More information about the asterisk-code-review mailing list