Module: kamailio Branch: 6.0 Commit: 9fae7141abd0f52d717bf37c742993ff578e7d95 URL: https://github.com/kamailio/kamailio/commit/9fae7141abd0f52d717bf37c742993ff578e7d95
Author: Alessio Garzi <[email protected]> Committer: Victor Seva <[email protected]> Date: 2026-05-15T11:48:06+02:00 pv_headers: Fix memory leak in pv_headers Before calling pvh_merge_uri(), c_data is allocated in shared memory. If an error occurs inside pvh_merge_uri(), this allocation is not released, leading to a potential leak. Additionally, pvh_merge_uri() may allocate further memory inside c_data->value.s, which also needs to be freed on failure. This commit ensures that all allocated memory is properly released in error paths, preventing potential memory leaks. (cherry picked from commit 97985752afa4fc1e80e3fc5daf70a11266145b29) (cherry picked from commit 1b2dad77102d8d8a0ef48225ad48f3d4f69719d7) --- Modified: src/modules/pv_headers/pvh_xavp.c --- Diff: https://github.com/kamailio/kamailio/commit/9fae7141abd0f52d717bf37c742993ff578e7d95.diff Patch: https://github.com/kamailio/kamailio/commit/9fae7141abd0f52d717bf37c742993ff578e7d95.patch --- diff --git a/src/modules/pv_headers/pvh_xavp.c b/src/modules/pv_headers/pvh_xavp.c index f416fdb0c83..4110d394853 100644 --- a/src/modules/pv_headers/pvh_xavp.c +++ b/src/modules/pv_headers/pvh_xavp.c @@ -713,7 +713,13 @@ xavp_c_data_t *pvh_set_parsed( return c_data; err: - // how can I call?? pvh_xavi_free_data(c_data, shm_free); + if(c_data != NULL) { + if(c_data->value.s != NULL) { + shm_free(c_data->value.s); + } + shm_free(c_data); + c_data = NULL; + } return NULL; } @@ -886,6 +892,13 @@ int pvh_set_uri(struct sip_msg *msg, pv_param_t *param, int op, pv_value_t *val) err: if(pv_format) pv_elem_free_all(pv_format); + if(c_data != NULL) { + if(c_data->value.s != NULL) { + shm_free(c_data->value.s); + } + shm_free(c_data); + c_data = NULL; + } return -1; } _______________________________________________ Kamailio - Development Mailing List -- [email protected] To unsubscribe send an email to [email protected] Important: keep the mailing list in the recipients, do not reply only to the sender!
