diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c index 12cf41deb3..bbdb8d148a 100644 --- a/res/res_pjsip_session.c +++ b/res/res_pjsip_session.c @@ -1315,8 +1315,10 @@ static void session_destructor(void *obj) struct ast_sip_session *session = obj; struct ast_sip_session_supplement *supplement; struct ast_sip_session_delayed_request *delay; + + /* We dup the endpoint ID in case the endpoint gets freed out from under us */ const char *endpoint_name = session->endpoint ? - ast_sorcery_object_get_id(session->endpoint) : ""; + ast_strdupa(ast_sorcery_object_get_id(session->endpoint)) : ""; ast_debug(3, "Destroying SIP session with endpoint %s\n", endpoint_name);