diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 4455483900..ace812c654 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -1572,6 +1572,12 @@ char *sofia_glue_get_url_from_contact(char *buf, uint8_t to_dup) } *e = '\0'; + } else { + if (to_dup) { + url = strdup(buf); + } else { + url = buf; + } } return url; diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 7d6f28e028..2a546d2758 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -530,16 +530,10 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * char *sub_to_user = argv[3]; char *sub_to_host = argv[4]; char *event = argv[5]; - char *contact = argv[6]; char *call_id = argv[7]; - //char *full_from = argv[8]; - //char *full_via = argv[9]; - //char *expires = argv[10]; - nua_handle_t *nh; char *to; char *open; - char *tmp; char *prpid; int done = 0; @@ -605,10 +599,6 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * id, profile->url, open, status, prpid, open, rpid, note); - - tmp = contact; - contact = sofia_glue_get_url_from_contact(tmp, 0); - nua_notify(nh, SIPTAG_SUBSCRIPTION_STATE_STR("active;expires=3600"), SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR("application/pidf+xml"), SIPTAG_PAYLOAD_STR(pl), TAG_END()); @@ -635,7 +625,7 @@ static int sofia_presence_mwi_callback(void *pArg, int argc, char **argv, char * char *sub_to_user = argv[3]; char *sub_to_host = argv[4]; char *event = argv[5]; - char *contact = argv[6]; + //char *contact = argv[6]; char *call_id = argv[7]; //char *full_from = argv[8]; //char *full_via = argv[9]; @@ -643,7 +633,7 @@ static int sofia_presence_mwi_callback(void *pArg, int argc, char **argv, char * char *body = argv[11]; char *exp; sofia_profile_t *profile = NULL; - char *tmp, *id = NULL; + char *id = NULL; nua_handle_t *nh; int expire_sec = atoi(expires); @@ -664,9 +654,6 @@ static int sofia_presence_mwi_callback(void *pArg, int argc, char **argv, char * } exp = switch_mprintf("active;expires=%ld", expire_sec); - tmp = contact; - contact = sofia_glue_get_url_from_contact(tmp, 0); - nua_notify(nh, SIPTAG_SUBSCRIPTION_STATE_STR(exp), SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"), SIPTAG_PAYLOAD_STR(body), TAG_END()); diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 09e2122ebb..c70b4cc8a6 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -156,18 +156,17 @@ int sofia_reg_nat_callback(void *pArg, int argc, char **argv, char **columnNames { sofia_profile_t *profile = (sofia_profile_t *) pArg; nua_handle_t *nh; - char *contact; + char *contact = NULL; char to[128] = ""; snprintf(to, sizeof(to), "%s@%s", argv[1], argv[2]); contact = sofia_glue_get_url_from_contact(argv[3], 1); nh = nua_handle(profile->nua, NULL, SIPTAG_FROM_STR(profile->url), SIPTAG_TO_STR(to), NUTAG_URL(contact), SIPTAG_CONTACT_STR(profile->url), TAG_END()); - - //nua_message(nh, SIPTAG_CONTENT_TYPE_STR("text/plain"), - //SIPTAG_PAYLOAD_STR("You suffer from Connectile Dysfunction.\nYou should use stun....\n"), TAG_END()); nua_options(nh, TAG_END()); + + switch_safe_free(contact); return 0; }