mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 03:20:57 +00:00
core_unreal.c: Fix memory leak in ast_unreal_new_channels()
When the channel tech is multistream capable, the reference to
chan_topology was passed to the new channel. When the channel tech
isn't multistream capable, the reference to chan_topology was never
released. "Local" channels are multistream capable so it didn't
affect them but the confbridge "CBAnn" and the bridge_media
"Recorder" channels are not so they caused a leak every time one
of them was created.
Also added tracing to ast_stream_topology_alloc() and
stream_topology_destroy() to assist with debugging.
Resolves: #938
(cherry picked from commit e434203810
)
This commit is contained in:
committed by
Asterisk Development Team
parent
b104c5837d
commit
5989b1ea02
@@ -641,27 +641,30 @@ struct ast_stream *ast_stream_create_resolved(struct ast_stream *pending_stream,
|
||||
static void stream_topology_destroy(void *data)
|
||||
{
|
||||
struct ast_stream_topology *topology = data;
|
||||
SCOPE_ENTER(4, "Topology: %p: %s\n", topology, ast_str_tmp(128, ast_stream_topology_to_str(topology, &STR_TMP)));
|
||||
|
||||
AST_VECTOR_CALLBACK_VOID(&topology->streams, ast_stream_free);
|
||||
AST_VECTOR_FREE(&topology->streams);
|
||||
SCOPE_EXIT_RTN("Destroyed: %p\n", topology);
|
||||
}
|
||||
|
||||
#define TOPOLOGY_INITIAL_STREAM_COUNT 2
|
||||
struct ast_stream_topology *ast_stream_topology_alloc(void)
|
||||
{
|
||||
struct ast_stream_topology *topology;
|
||||
SCOPE_ENTER(4, "Topology Create\n");
|
||||
|
||||
topology = ao2_alloc_options(sizeof(*topology), stream_topology_destroy, AO2_ALLOC_OPT_LOCK_NOLOCK);
|
||||
if (!topology) {
|
||||
return NULL;
|
||||
SCOPE_EXIT_RTN_VALUE(NULL, "Allocation failed\n");
|
||||
}
|
||||
|
||||
if (AST_VECTOR_INIT(&topology->streams, TOPOLOGY_INITIAL_STREAM_COUNT)) {
|
||||
ao2_ref(topology, -1);
|
||||
topology = NULL;
|
||||
SCOPE_EXIT_RTN_VALUE(NULL, "Vector init failed\n");
|
||||
}
|
||||
|
||||
return topology;
|
||||
SCOPE_EXIT_RTN_VALUE(topology, "Created: %p\n", topology);
|
||||
}
|
||||
|
||||
struct ast_stream_topology *ast_stream_topology_clone(
|
||||
|
Reference in New Issue
Block a user