]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res_musiconhold: Fix mohclass reference leak on answeredonly early return. master
authoraabolfazl <aabolfazlit@gmail.com>
Sun, 2 Aug 2026 16:49:37 +0000 (19:49 +0300)
committergithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Tue, 4 Aug 2026 17:24:47 +0000 (17:24 +0000)
commitc46c9945a89f43b7e07fdd9fd787c8d78761d5f3
treeddde42e4d4a41d7b4ff6f8386e0d977253b5fa57
parent5b5982901594d5b414960198c8beb2515e3b0fe0
res_musiconhold: Fix mohclass reference leak on answeredonly early return.

local_ast_moh_start() returns -1 from the answeredonly check without
releasing the mohclass reference it holds, unlike every other exit path
in the function. Nothing else ever releases that reference, so
moh_class_destructor() never runs for the object. With realtime music
on hold and cachertclasses disabled, each suppressed request leaks the
class object, its monitor thread, the external application process and
two file descriptors for the lifetime of Asterisk. For static classes
the stale references prevent the class from ever being destroyed after
it is replaced by a reload.

Release the reference before returning, matching the other exit paths.

Fixes: #2051
res/res_musiconhold.c