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().
This commit is contained in:
George Joseph
2025-01-23 14:02:25 -07:00
parent 04f4bd73cd
commit 00de10c0d1
4 changed files with 14 additions and 41 deletions

View File

@@ -1333,7 +1333,7 @@ enum ast_sip_check_auth_result {
* \brief Populate a vector of algorithm types from a string.
*
* \param id The object id to use in error messages
* \param algorithms The vector to populate
* \param algorithms The initialized but empty vector to populate
* \param agent_type The type of agent to use in error messages ("UAC" or "UAS")
* \param value The comma-separated string to parse for algorithms
*