summaryrefslogtreecommitdiff
path: root/agent/discovery.c
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2014-09-19 09:56:21 +0100
committerPhilip Withnall <philip.withnall@collabora.co.uk>2014-09-19 09:56:21 +0100
commit5ed865fbf61a381319ac643f3ba8fd2394f457b3 (patch)
treeb07e248042679e2a18039f6e4b6a6e5b11ae1d03 /agent/discovery.c
parente5fbdbe605b0acc74e259a1618e2fe2304becade (diff)
downloadlibnice-5ed865fbf61a381319ac643f3ba8fd2394f457b3.tar.gz
agent: Clear existing GSource timeouts before adding new ones
Modify agent_timeout_add_with_context() to force destroying and freeing of an existing GSource before overwriting it with a new one (probably with an updated timeout period). This fixes a case in priv_map_reply_to_relay_refresh() where the TURN candidate refresh timer was being overwritten with a new one, without the old one being destroyed. This lead to two timeouts existing, only one of which would be destroyed when the CandidateRefresh struct was freed, leaking the other one (in the main context) and allowing it to be later dispatched with a dangling CandidateRefresh pointer. The modification to agent_timeout_add_with_context() should prevent this happening in new code in future.
Diffstat (limited to 'agent/discovery.c')
-rw-r--r--agent/discovery.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/agent/discovery.c b/agent/discovery.c
index c5d9220..83cd3c2 100644
--- a/agent/discovery.c
+++ b/agent/discovery.c
@@ -1169,10 +1169,9 @@ void discovery_schedule (NiceAgent *agent)
/* step: run first iteration immediately */
gboolean res = priv_discovery_tick_unlocked (agent);
if (res == TRUE) {
- agent->discovery_timer_source =
- agent_timeout_add_with_context (agent,
- "Candidate discovery tick", agent->timer_ta,
- priv_discovery_tick, agent);
+ agent_timeout_add_with_context (agent, &agent->discovery_timer_source,
+ "Candidate discovery tick", agent->timer_ta,
+ priv_discovery_tick, agent);
}
}
}