Skip to content

Commit

Permalink
usrloc: fix event trigger when no socket is used
Browse files Browse the repository at this point in the history
Without this fix, opensips crashes when trying to add a contact from MI
or when loading a user from DB without a socket or with an unknown
socket.

Reported by Cindy Leung on mailing list

(cherry picked from commit a829445)
  • Loading branch information
razvancrainea committed May 10, 2017
1 parent 02d312d commit 09e259f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions modules/usrloc/udomain.c
Expand Up @@ -305,9 +305,10 @@ static void ul_raise_event(event_id_t _e, struct urecord* _r)
LM_ERR("cannot raise event\n");
}


void ul_raise_contact_event(event_id_t _e, struct ucontact *_c)
{
static str str_empty = {"", 0};

if (_e == EVI_ERROR) {
LM_ERR("event not yet registered %d\n", _e);
return;
Expand Down Expand Up @@ -344,7 +345,8 @@ void ul_raise_contact_event(event_id_t _e, struct ucontact *_c)
}

/* the socket */
if (evi_param_set_str(ul_c_socket_param, &_c->sock->sock_str) < 0) {
if (evi_param_set_str(ul_c_socket_param,
(_c->sock ? &_c->sock->sock_str : &str_empty)) < 0) {
LM_ERR("cannot set socket parameter\n");
return;
}
Expand Down

0 comments on commit 09e259f

Please sign in to comment.