aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Kluchnikov <kluchnikovi@gmail.com>2016-11-03 22:05:11 +0300
committerIvan Kluchnikov <kluchnikovi@gmail.com>2017-02-07 18:59:56 +0300
commitfdee81b35f8c8d3f96a085d64a10399ae3e41ee0 (patch)
tree44b41caed69b6e94def104c139eb17b6bbf59c94
parent582242d2f5302067a7ed019e8bf4d3e806c9047d (diff)
reg-proxy: free all allocated osip elements, messages and transactions
-rw-r--r--openbsc/src/reg-proxy/sip.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/openbsc/src/reg-proxy/sip.c b/openbsc/src/reg-proxy/sip.c
index 1e9f256d2..a33e14157 100644
--- a/openbsc/src/reg-proxy/sip.c
+++ b/openbsc/src/reg-proxy/sip.c
@@ -40,6 +40,7 @@ int sip_send(struct sip_client *sip_client, osip_t *osip,
status = osip_transaction_init(&transaction, transaction_type, osip, msg);
if (status) {
printf("Failed to init transaction %d",status);
+ osip_message_free(msg);
return -1;
}
@@ -122,6 +123,7 @@ int tx_sip_register(struct sip_client *sip_client, osip_t *osip, char *imsi)
sprintf(call_id_num, "%u", osip_build_random_number());
osip_call_id_set_number(call_id, call_id_num);
reg_msg->call_id = call_id;
+ osip_free(call_id_num);
if (osip_cseq_init(&cseq)) {
OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_BUG,NULL,"seq init failed!\n"));
@@ -134,6 +136,7 @@ int tx_sip_register(struct sip_client *sip_client, osip_t *osip, char *imsi)
osip_cseq_set_number(cseq, seq_num_str);
osip_cseq_set_method(cseq, osip_strdup("REGISTER"));
reg_msg->cseq = cseq;
+ osip_free(seq_num_str);
osip_message_set_max_forwards(reg_msg, "70");
@@ -213,12 +216,16 @@ int sip_cb_send(osip_transaction_t *tr, osip_message_t *sip_msg, char *host, int
printf("SIP Send Msg\n");
if ((err = osip_message_to_str(sip_msg, &msg_p, &msg_len)) != 0){
+ osip_message_free(sip_msg);
+ msgb_free(msg);
printf("SIP failed to convert message: %d\n", err);
return -1;
}
printf("SIP convert message ok\n");
if (!msg_p) {
+ msgb_free(msg);
+ osip_message_free(sip_msg);
printf("SIP msg_p = NULL fail!\n");
return -1;
}
@@ -226,6 +233,9 @@ int sip_cb_send(osip_transaction_t *tr, osip_message_t *sip_msg, char *host, int
if (sip_client == NULL) {
osip_dialog_t* diag = (osip_dialog_t* )sip_msg->application_data;
if (diag == NULL) {
+ msgb_free(msg);
+ osip_free(msg_p);
+ osip_message_free(sip_msg);
printf("Unable to send:\n%s\n", msg_p);
return -1;
}
@@ -237,6 +247,7 @@ int sip_cb_send(osip_transaction_t *tr, osip_message_t *sip_msg, char *host, int
msg->data_len = msg_len;
msg->len += msg_len;
printf("SIP ready to send msg via IPA\n");
+ osip_free(msg_p);
return sip_client_send(sip_client, msg);
}
@@ -260,14 +271,14 @@ void sip_cb_rcv2xx(int type, osip_transaction_t *tr, osip_message_t *sip_msg)
to = osip_message_get_to(sip_msg);
memcpy(imsi, to->url->username, 16);
-
+ osip_message_free(sip_msg);
printf("OSIP_NICT_STATUS_2XX_RECEIVED imsi = %s \n", imsi);
printf("OSIP_NICT_STATUS_2XX_RECEIVED msisdn = %d \n", msisdn);
printf("OSIP_NICT_STATUS_2XX_RECEIVED msisdn = %s \n", msisdn);
handle_location_update_result(reg->sup_server, imsi, msisdn);
-
+ osip_transaction_free(tr);
}
void sip_cb_rcv2xx_again(int type, osip_transaction_t *pott,osip_message_t *pomt)