Module: kamailio
Branch: master
Commit: 395303dbb3572e57bd8d16bcbbfb29d6d54a60fe
URL:
https://github.com/kamailio/kamailio/commit/395303dbb3572e57bd8d16bcbbfb29d…
Author: Stefan Mititelu <stefan.mititelu92(a)gmail.com>
Committer: Stefan Mititelu <stefan.mititelu(a)enea.com>
Date: 2020-03-05T10:25:18+02:00
corex: check not in SHM before PKG free for path
Do the same for reset_path_vector() in core msg parser.
---
Modified: src/core/parser/msg_parser.c
Modified: src/modules/corex/corex_lib.c
---
Diff:
https://github.com/kamailio/kamailio/commit/395303dbb3572e57bd8d16bcbbfb29d…
Patch:
https://github.com/kamailio/kamailio/commit/395303dbb3572e57bd8d16bcbbfb29d…
---
diff --git a/src/core/parser/msg_parser.c b/src/core/parser/msg_parser.c
index 91095bf574..ca0bf789c5 100644
--- a/src/core/parser/msg_parser.c
+++ b/src/core/parser/msg_parser.c
@@ -806,11 +806,14 @@ int set_path_vector(struct sip_msg* msg, str* path)
void reset_path_vector(struct sip_msg* const msg)
{
- if (msg->path_vec.s) {
- pkg_free(msg->path_vec.s);
+ if (!shm_address_in(msg->path_vec.s)) {
+ if (msg->path_vec.s)
+ pkg_free(msg->path_vec.s);
+ msg->path_vec.s = 0;
+ msg->path_vec.len = 0;
+ } else {
+ LM_WARN("Found path_vec that is not in pkg mem!\n");
}
- msg->path_vec.s = 0;
- msg->path_vec.len = 0;
}
diff --git a/src/modules/corex/corex_lib.c b/src/modules/corex/corex_lib.c
index ec5334cb2e..3d3f73c0bd 100644
--- a/src/modules/corex/corex_lib.c
+++ b/src/modules/corex/corex_lib.c
@@ -63,11 +63,13 @@ int corex_append_branch(sip_msg_t *msg, str *uri, str *qv)
msg->dst_uri.len = 0;
/* if this is a cloned message, don't free the path vector as it was copied into
shm memory and will be freed as contiguous block*/
- if (!(msg->msg_flags&FL_SHM_CLONE)) {
- if(msg->path_vec.s!=0)
+ if (!shm_address_in(msg->path_vec.s)) {
+ if (msg->path_vec.s)
pkg_free(msg->path_vec.s);
msg->path_vec.s = 0;
msg->path_vec.len = 0;
+ } else {
+ LM_WARN("Found path_vec that is not in pkg mem!\n");
}
}