]> 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>
Wed, 29 Jan 2025 17:00:47 +0000 (10:00 -0700)
commit00de10c0d1a07ba27c50eb224c4a200e5f89b88c
tree7e21080bcbf6f37030558c42368069650f5b3f01
parent04f4bd73cd6fc804059be4f236a5527d98c56587
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