diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2022-02-04 17:20:52 -0500 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@ocrete.ca> | 2022-04-20 16:31:23 +0000 |
commit | 41ac7386b2d8fc2215f244e899e70e536decc83e (patch) | |
tree | fbe35c99f40864c0de3a8c2e916aef11510f1f6b | |
parent | 526eec8beaf9068b66caab6e1f941ec574e3b82a (diff) | |
download | libnice-41ac7386b2d8fc2215f244e899e70e536decc83e.tar.gz |
agent: Hold ref while doing async close
It's possible that the callback will be called synchronously during the
close function, in this case, we need to be ready to the last reference
to the agent to be dropped in this callback.
This fix was suggested by Fabrice Bellet
Fixes #153
-rw-r--r-- | agent/agent.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/agent/agent.c b/agent/agent.c index 0765ad9..8cde228 100644 --- a/agent/agent.c +++ b/agent/agent.c @@ -7374,11 +7374,16 @@ nice_agent_close_async (NiceAgent *agent, GAsyncReadyCallback callback, task = g_task_new (agent, NULL, callback, callback_data); g_task_set_source_tag (task, nice_agent_close_async); + /* Hold an extra ref here in case the application releases the last ref + * during the callback. + */ + g_object_ref (agent); agent_lock (agent); refresh_prune_agent_async (agent, on_agent_refreshes_pruned, task); agent_unlock (agent); + g_object_unref (agent); } |