There's a risk that unlink() gets called recursively, and if that happens, it's best to exit the function as soon as possible. I removed the check from pa_node_free(), because it's really pretty redundant. --- src/pulsecore/node.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pulsecore/node.c b/src/pulsecore/node.c index 5d1397b..3ef35e3 100644 --- a/src/pulsecore/node.c +++ b/src/pulsecore/node.c @@ -158,8 +158,7 @@ fail: void pa_node_free(pa_node *node) { pa_assert(node); - if (!node->unlinked) - pa_node_unlink(node); + pa_node_unlink(node); pa_xfree(node->description); @@ -406,8 +405,12 @@ int pa_node_put(pa_node *node, pa_node **requested_connections, unsigned n_reque void pa_node_unlink(pa_node *node) { pa_assert(node); - if (node->unlinked) + if (node->unlinked) { + pa_log_debug("Unlinking node %s (already unlinked, this is a no-op).", node->name); return; + } + + node->unlinked = true; pa_log_debug("Unlinking node %s.", node->name); @@ -416,7 +419,6 @@ void pa_node_unlink(pa_node *node) { pa_assert_se(pa_idxset_remove_by_index(node->core->nodes, node->index)); - node->unlinked = true; } void pa_node_active_changed(pa_node *node, bool new_active) { -- 1.8.3.1