diff options
author | Benny Prijono <bennylp@teluu.com> | 2008-12-17 14:28:18 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2008-12-17 14:28:18 +0000 |
commit | 30d11975f4123b0dfd06b1ba6d36b8e0bbe09a51 (patch) | |
tree | 401cad084f7d2fab6935488a5fcf575f5384bbac /pjsip/src/pjsip/sip_transport.c | |
parent | b6529acff90535f3f54b57d093bae7bc90139bff (diff) |
Ticket 684: protect the memory allocation for TX packet with try/catch, and fixed various transmit data buffer leaks when transmission fails immediately
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2380 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsip/sip_transport.c')
-rw-r--r-- | pjsip/src/pjsip/sip_transport.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/pjsip/src/pjsip/sip_transport.c b/pjsip/src/pjsip/sip_transport.c index 9727858b..15f39dec 100644 --- a/pjsip/src/pjsip/sip_transport.c +++ b/pjsip/src/pjsip/sip_transport.c @@ -568,8 +568,17 @@ static pj_status_t mod_on_tx_msg(pjsip_tx_data *tdata) { /* Allocate buffer if necessary. */ if (tdata->buf.start == NULL) { - tdata->buf.start = (char*) - pj_pool_alloc( tdata->pool, PJSIP_MAX_PKT_LEN); + PJ_USE_EXCEPTION; + + PJ_TRY { + tdata->buf.start = (char*) + pj_pool_alloc(tdata->pool, PJSIP_MAX_PKT_LEN); + } + PJ_CATCH_ANY { + return PJ_ENOMEM; + } + PJ_END + tdata->buf.cur = tdata->buf.start; tdata->buf.end = tdata->buf.start + PJSIP_MAX_PKT_LEN; } |