Module: kamailio
Branch: master
Commit: 62e822ce25e93a8183dd9e5e1fee517143849a6a
URL:
https://github.com/kamailio/kamailio/commit/62e822ce25e93a8183dd9e5e1fee517…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-04-07T09:53:39+02:00
core: use same condition for extra_params in create_via_hf()
---
Modified: src/core/msg_translator.c
---
Diff:
https://github.com/kamailio/kamailio/commit/62e822ce25e93a8183dd9e5e1fee517…
Patch:
https://github.com/kamailio/kamailio/commit/62e822ce25e93a8183dd9e5e1fee517…
---
diff --git a/src/core/msg_translator.c b/src/core/msg_translator.c
index c3587d2e88..4622b264d5 100644
--- a/src/core/msg_translator.c
+++ b/src/core/msg_translator.c
@@ -2992,12 +2992,14 @@ char* create_via_hf(unsigned int *len,
/* params so far + ';rport' + '\0' */
via = (char*)pkg_malloc(extra_params.len+RPORT_LEN);
if(via==0) {
- PKG_MEM_ERROR;
+ PKG_MEM_ERROR;
if (extra_params.s) pkg_free(extra_params.s);
return 0;
}
- if(extra_params.len!=0) {
+ if(extra_params.s!=NULL && extra_params.len>0) {
memcpy(via, extra_params.s, extra_params.len);
+ }
+ if(extra_params.s!=NULL) {
pkg_free(extra_params.s);
}
memcpy(via + extra_params.len, RPORT, RPORT_LEN-1);
@@ -3018,8 +3020,10 @@ char* create_via_hf(unsigned int *len,
if (extra_params.s) pkg_free(extra_params.s);
return 0;
}
- if(extra_params.len != 0) {
+ if(extra_params.s!=NULL && extra_params.len>0) {
memcpy(via, extra_params.s, extra_params.len);
+ }
+ if(extra_params.s!=NULL) {
pkg_free(extra_params.s);
}
memcpy(via + extra_params.len, sbuf, slen);
@@ -3038,12 +3042,14 @@ char* create_via_hf(unsigned int *len,
if(xparams.len>0) {
via = (char*)pkg_malloc(extra_params.len+xparams.len+2);
if(via==0) {
- PKG_MEM_ERROR;
+ PKG_MEM_ERROR;
if (extra_params.s) pkg_free(extra_params.s);
return 0;
}
- if(extra_params.len != 0) {
+ if(extra_params.s!=NULL && extra_params.len>0) {
memcpy(via, extra_params.s, extra_params.len);
+ }
+ if(extra_params.s!=NULL) {
pkg_free(extra_params.s);
}
/* add ';' between via parameters */