[sr-dev] git:5.2:1a142067: corex: check not in SHM before PKG free for path
Henning Westerholt
hw at skalatan.de
Thu Mar 5 12:46:05 CET 2020
Module: kamailio
Branch: 5.2
Commit: 1a142067b04e41b98ce2f8d7f0946c2dcbd7914f
URL: https://github.com/kamailio/kamailio/commit/1a142067b04e41b98ce2f8d7f0946c2dcbd7914f
Author: Stefan Mititelu <stefan.mititelu92 at gmail.com>
Committer: Henning Westerholt <hw at skalatan.de>
Date: 2020-03-05T12:45:41+01:00
corex: check not in SHM before PKG free for path
Do the same for reset_path_vector() in core msg parser.
(cherry picked from commit 395303dbb3572e57bd8d16bcbbfb29d6d54a60fe)
---
Modified: src/core/parser/msg_parser.c
Modified: src/modules/corex/corex_lib.c
---
Diff: https://github.com/kamailio/kamailio/commit/1a142067b04e41b98ce2f8d7f0946c2dcbd7914f.diff
Patch: https://github.com/kamailio/kamailio/commit/1a142067b04e41b98ce2f8d7f0946c2dcbd7914f.patch
---
diff --git a/src/core/parser/msg_parser.c b/src/core/parser/msg_parser.c
index c220a5bb5c..0a8506e5a3 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");
}
}
More information about the sr-dev
mailing list