[Asterisk-code-review] res pjsip: Fix pointer use after unref. (asterisk[14])
Richard Mudgett
asteriskteam at digium.com
Mon Apr 10 13:12:01 CDT 2017
Richard Mudgett has uploaded a new change for review. ( https://gerrit.asterisk.org/5438 )
Change subject: res_pjsip: Fix pointer use after unref.
......................................................................
res_pjsip: Fix pointer use after unref.
Change-Id: I4b6e1b0070563eeaee223cb58326f1b962ed5bc1
---
M res/res_pjsip/config_transport.c
1 file changed, 8 insertions(+), 7 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/38/5438/1
diff --git a/res/res_pjsip/config_transport.c b/res/res_pjsip/config_transport.c
index 3c41f17..a1127c2 100644
--- a/res/res_pjsip/config_transport.c
+++ b/res/res_pjsip/config_transport.c
@@ -286,15 +286,16 @@
static struct ast_sip_transport_state *find_state_by_transport(const struct ast_sip_transport *transport)
{
struct internal_state *state;
+ struct ast_sip_transport_state *trans_state;
state = find_internal_state_by_transport(transport);
if (!state) {
return NULL;
}
- ao2_bump(state->state);
+ trans_state = ao2_bump(state->state);
ao2_cleanup(state);
- return state->state;
+ return trans_state;
}
static int remove_temporary_state(void)
@@ -1297,22 +1298,22 @@
struct ast_sip_transport_state *ast_sip_get_transport_state(const char *transport_id)
{
- struct internal_state * state = NULL;
+ struct internal_state *state = NULL;
+ struct ast_sip_transport_state *trans_state;
if (!transport_states) {
return NULL;
}
state = ao2_find(transport_states, transport_id, OBJ_SEARCH_KEY);
- if (!state || !state->state) {
- ao2_cleanup(state);
+ if (!state) {
return NULL;
}
- ao2_ref(state->state, +1);
+ trans_state = ao2_bump(state->state);
ao2_ref(state, -1);
- return state->state;
+ return trans_state;
}
static int populate_transport_states(void *obj, void *arg, int flags)
--
To view, visit https://gerrit.asterisk.org/5438
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4b6e1b0070563eeaee223cb58326f1b962ed5bc1
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
More information about the asterisk-code-review
mailing list