Skip to content

Commit

Permalink
xmlrpc: reset fields in case of error for building fake via
Browse files Browse the repository at this point in the history
(cherry picked from commit b54573c)
  • Loading branch information
miconda committed Sep 24, 2019
1 parent 40e1dba commit 7454753
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/modules/xmlrpc/http.c
Expand Up @@ -67,14 +67,14 @@ static int insert_fake_via(sip_msg_t* msg, char* via, int via_len)
LM_ERR("out of pkg memory\n");
goto error;
}
memset(vb, 0, sizeof(struct via_body));

msg->h_via1 = pkg_malloc(sizeof(hdr_field_t));
if (!msg->h_via1) {
ERR("No memory left\n");
goto error;
}
memset(msg->h_via1, 0, sizeof(hdr_field_t));
memset(vb, 0, sizeof(struct via_body));

/* FIXME: The code below would break if the VIA prefix
* gets changed in config.h
Expand Down Expand Up @@ -121,10 +121,12 @@ static int insert_fake_via(sip_msg_t* msg, char* via, int via_len)
error:
if (vb) {
free_via_list(vb);
pkg_free(vb);
}

if (msg->h_via1) pkg_free(msg->h_via1);
if (msg->h_via1) {
pkg_free(msg->h_via1);
msg->h_via1 = 0;
}
return -1;
}

Expand Down

0 comments on commit 7454753

Please sign in to comment.