From 2db81ee2b465c1c8f9c9e20359310b61e2f5e0f6 Mon Sep 17 00:00:00 2001 From: Paulo Vicentini <paulo.vicentini@gmail.com> Date: Wed, 13 Feb 2019 14:36:45 +0100 Subject: [PATCH] res/res_pjsip: Resources (udptl fd) are leaking for T.38 calls Fix unbalanced references for datastore t38_session_media ASTERISK-28288 Change-Id: Id6dceceb06651b03f611bf33deb3061022fe5d0c --- res/res_pjsip_t38.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/res/res_pjsip_t38.c b/res/res_pjsip_t38.c index cd225d4b11..62bbb48ef2 100644 --- a/res/res_pjsip_t38.c +++ b/res/res_pjsip_t38.c @@ -147,18 +147,23 @@ static struct ast_sip_session_media *session_media_from_datastore_addref(struct } /*! \brief Helper function which allocates datastore with a session media */ -static struct ast_datastore *create_datastore_session_media(struct ast_sip_session *session, struct ast_sip_session_media *session_media) +static int create_datastore_session_media(struct ast_sip_session *session, struct ast_sip_session_media *session_media) { struct ast_datastore *datastore = NULL; - if (!(datastore = ast_sip_session_alloc_datastore(&session_media_datastore, "t38_session_media")) - || ast_sip_session_add_datastore(session, datastore)) { - return NULL; + if (!(datastore = ast_sip_session_alloc_datastore(&session_media_datastore, "t38_session_media"))) { + return -1; + } + + if (ast_sip_session_add_datastore(session, datastore)) { + ao2_ref(datastore, -1); + return -1; } datastore->data = session_media; ao2_bump(session_media); - return datastore; + ao2_ref(datastore, -1); + return 0; } /*! \brief Helper function for changing the T.38 state */ @@ -296,7 +301,7 @@ static int t38_initialize_session(struct ast_sip_session *session, struct ast_si return 0; } - if (!create_datastore_session_media(session, session_media)) { + if (create_datastore_session_media(session, session_media)) { return -1; } -- GitLab