]> git.ipfire.org Git - thirdparty/asterisk.git/commit
resource_channels.c: Fix memory leak in ast_ari_channels_external_media.
authorGeorge Joseph <gjoseph@sangoma.com>
Tue, 4 Feb 2025 20:00:16 +0000 (13:00 -0700)
committerAsterisk Development Team <asteriskteam@digium.com>
Thu, 20 Mar 2025 18:34:07 +0000 (18:34 +0000)
commit619cb75688d17fafd3761ba130cecd97f6c47b21
tree538fb2c5695d175e8c02ea5a7b3c6aa3b84890bf
parentfe5ff3021e68e33774ec6dffdfa5af3e435a047d
resource_channels.c: Fix memory leak in ast_ari_channels_external_media.

Between ast_ari_channels_external_media(), external_media_rtp_udp(),
and external_media_audiosocket_tcp(), the `variables` structure being passed
around wasn't being cleaned up properly when there was a failure.

* In ast_ari_channels_external_media(), the `variables` structure is now
  defined with RAII_VAR to ensure it always gets cleaned up.

* The ast_variables_destroy() call was removed from external_media_rtp_udp().

* The ast_variables_destroy() call was removed from
  external_media_audiosocket_tcp(), its `endpoint` allocation was changed to
  to use ast_asprintf() as external_media_rtp_udp() does, and it now
  returns an error on failure.

* ast_ari_channels_external_media() now checks the new return code from
  external_media_audiosocket_tcp() and sets the appropriate error response.

Resolves: #1109
(cherry picked from commit 1a1eb8821185c0f4945d6ca0654ea6763e1560fb)
res/ari/resource_channels.c