]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res_pjsip: Fix startup/reload memory leak in config_auth.
authorGeorge Joseph <gjoseph@sangoma.com>
Thu, 23 Jan 2025 21:02:25 +0000 (14:02 -0700)
committerGeorge Joseph <gjoseph@sangoma.com>
Mon, 27 Jan 2025 17:20:20 +0000 (17:20 +0000)
commit8da4b051073a29f4d54fc9bc5b203e691f0a7de0
tree6dfca95f70291ff6be67034d6063d391f3de7d0c
parentf6a193e87eaa04af0058c45d78e2c41f5c94dcea
res_pjsip: Fix startup/reload memory leak in config_auth.

An issue in config_auth.c:ast_sip_auth_digest_algorithms_vector_init() was
causing double allocations for the two supported_algorithms vectors to the
tune of 915 bytes.  The leak only happens on startup and when a reload is done
and doesn't get bigger with the number of auth objects defined.

* Pre-initialized the two vectors in config_auth:auth_alloc().
* Removed the allocations in ast_sip_auth_digest_algorithms_vector_init().
* Added a note to the doc for ast_sip_auth_digest_algorithms_vector_init()
  noting that the vector passed in should be initialized and empty.
* Simplified the create_artificial_auth() function in pjsip_distributor.
* Set the vector initialization count to 0 in config_global:global_apply().
include/asterisk/res_pjsip.h
res/res_pjsip/config_auth.c
res/res_pjsip/config_global.c
res/res_pjsip/pjsip_distributor.c