Commit 282e8dae authored by Youness Alaoui's avatar Youness Alaoui

free candidates returned by nice_agent_get_local_candidates

parent 580afc6c
...@@ -202,6 +202,8 @@ static void priv_get_local_addr (NiceAgent *agent, guint stream_id, guint compon ...@@ -202,6 +202,8 @@ static void priv_get_local_addr (NiceAgent *agent, guint stream_id, guint compon
break; break;
} }
} }
for (i = cands; i; i = i->next)
nice_candidate_free ((NiceCandidate *) i->data);
g_slist_free (cands); g_slist_free (cands);
} }
......
...@@ -263,6 +263,8 @@ static void priv_get_local_addr (NiceAgent *agent, guint stream_id, guint compon ...@@ -263,6 +263,8 @@ static void priv_get_local_addr (NiceAgent *agent, guint stream_id, guint compon
*dstaddr = cand->addr; *dstaddr = cand->addr;
} }
} }
for (i = cands; i; i = i->next)
nice_candidate_free ((NiceCandidate *) i->data);
g_slist_free (cands); g_slist_free (cands);
} }
...@@ -279,8 +281,11 @@ static GSList *priv_get_local_candidate (NiceAgent *agent, guint stream_id, guin ...@@ -279,8 +281,11 @@ static GSList *priv_get_local_candidate (NiceAgent *agent, guint stream_id, guin
out_cand = cand; out_cand = cand;
} }
} }
result = g_slist_append (result, nice_candidate_copy (out_cand));
for (i = cands; i; i = i->next)
nice_candidate_free ((NiceCandidate *) i->data);
g_slist_free (cands); g_slist_free (cands);
result = g_slist_append (result, out_cand);
return result; return result;
} }
...@@ -300,7 +305,7 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas ...@@ -300,7 +305,7 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
{ {
// NiceAddress laddr, raddr, laddr_rtcp, raddr_rtcp; // NiceAddress laddr, raddr, laddr_rtcp, raddr_rtcp;
NiceCandidate cdes; NiceCandidate cdes;
GSList *cands; GSList *cands, *i;
guint ls_id, rs_id; guint ls_id, rs_id;
init_candidate (&cdes); init_candidate (&cdes);
...@@ -407,15 +412,23 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas ...@@ -407,15 +412,23 @@ static int run_full_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress *bas
g_slist_free (cands);*/ g_slist_free (cands);*/
cands = priv_get_local_candidate (ragent, rs_id, NICE_COMPONENT_TYPE_RTP); cands = priv_get_local_candidate (ragent, rs_id, NICE_COMPONENT_TYPE_RTP);
nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, cands); nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTP, cands);
for (i = cands; i; i = i->next)
nice_candidate_free ((NiceCandidate *) i->data);
g_slist_free (cands); g_slist_free (cands);
cands = priv_get_local_candidate (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP); cands = priv_get_local_candidate (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP);
nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP, cands); nice_agent_set_remote_candidates (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP, cands);
for (i = cands; i; i = i->next)
nice_candidate_free ((NiceCandidate *) i->data);
g_slist_free (cands); g_slist_free (cands);
cands = priv_get_local_candidate (lagent, ls_id, NICE_COMPONENT_TYPE_RTP); cands = priv_get_local_candidate (lagent, ls_id, NICE_COMPONENT_TYPE_RTP);
nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTP, cands); nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTP, cands);
for (i = cands; i; i = i->next)
nice_candidate_free ((NiceCandidate *) i->data);
g_slist_free (cands); g_slist_free (cands);
cands = priv_get_local_candidate (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP); cands = priv_get_local_candidate (lagent, ls_id, NICE_COMPONENT_TYPE_RTCP);
nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP, cands); nice_agent_set_remote_candidates (ragent, rs_id, NICE_COMPONENT_TYPE_RTCP, cands);
for (i = cands; i; i = i->next)
nice_candidate_free ((NiceCandidate *) i->data);
g_slist_free (cands); g_slist_free (cands);
g_debug ("test-fullmode: Set properties, next running mainloop until connectivity checks succeed..."); g_debug ("test-fullmode: Set properties, next running mainloop until connectivity checks succeed...");
...@@ -672,6 +685,8 @@ static int run_full_test_wrong_password (NiceAgent *lagent, NiceAgent *ragent, N ...@@ -672,6 +685,8 @@ static int run_full_test_wrong_password (NiceAgent *lagent, NiceAgent *ragent, N
laddr = cand->addr; laddr = cand->addr;
} }
} }
for (i = cands; i; i = i->next)
nice_candidate_free ((NiceCandidate *) i->data);
g_slist_free (cands); g_slist_free (cands);
cands = nice_agent_get_local_candidates(ragent, rs_id, NICE_COMPONENT_TYPE_RTP); cands = nice_agent_get_local_candidates(ragent, rs_id, NICE_COMPONENT_TYPE_RTP);
...@@ -791,6 +806,8 @@ static int run_full_test_control_conflict (NiceAgent *lagent, NiceAgent *ragent, ...@@ -791,6 +806,8 @@ static int run_full_test_control_conflict (NiceAgent *lagent, NiceAgent *ragent,
laddr = cand->addr; laddr = cand->addr;
} }
} }
for (i = cands; i; i = i->next)
nice_candidate_free ((NiceCandidate *) i->data);
g_slist_free (cands); g_slist_free (cands);
cands = nice_agent_get_local_candidates(ragent, rs_id, NICE_COMPONENT_TYPE_RTP); cands = nice_agent_get_local_candidates(ragent, rs_id, NICE_COMPONENT_TYPE_RTP);
...@@ -971,6 +988,7 @@ int main (void) ...@@ -971,6 +988,7 @@ int main (void)
g_assert (global_lagent_cands == 2); g_assert (global_lagent_cands == 2);
g_assert (global_ragent_cands == 2); g_assert (global_ragent_cands == 2);
/* run test with incorrect credentials (make sure process fails) */ /* run test with incorrect credentials (make sure process fails) */
g_debug ("test-fullmode: TEST STARTS / incorrect credentials"); g_debug ("test-fullmode: TEST STARTS / incorrect credentials");
result = run_full_test_wrong_password (lagent, ragent, &baseaddr); result = run_full_test_wrong_password (lagent, ragent, &baseaddr);
......
...@@ -87,12 +87,14 @@ main (void) ...@@ -87,12 +87,14 @@ main (void)
{ {
NiceCandidate *candidate; NiceCandidate *candidate;
GSList *candidates; GSList *candidates, *i;
candidates = nice_agent_get_local_candidates (agent, 1, 1); candidates = nice_agent_get_local_candidates (agent, 1, 1);
candidate = candidates->data; candidate = candidates->data;
nice_socket_send (candidate->sockptr, &(candidate->addr), 6, "\x80hello"); nice_socket_send (candidate->sockptr, &(candidate->addr), 6, "\x80hello");
for (i = candidates; i; i = i->next)
nice_candidate_free ((NiceCandidate *) i->data);
g_slist_free (candidates); g_slist_free (candidates);
} }
......
...@@ -188,6 +188,8 @@ static void priv_get_local_addr (NiceAgent *agent, guint stream_id, guint compon ...@@ -188,6 +188,8 @@ static void priv_get_local_addr (NiceAgent *agent, guint stream_id, guint compon
*dstaddr = cand->addr; *dstaddr = cand->addr;
} }
} }
for (i = cands; i; i = i->next)
nice_candidate_free ((NiceCandidate *) i->data);
g_slist_free (cands); g_slist_free (cands);
} }
......
...@@ -94,8 +94,8 @@ cb_new_selected_pair(NiceAgent *agent, ...@@ -94,8 +94,8 @@ cb_new_selected_pair(NiceAgent *agent,
static void cb_candidate_gathering_done(NiceAgent *agent, guint stream_id, gpointer data) static void cb_candidate_gathering_done(NiceAgent *agent, guint stream_id, gpointer data)
{ {
NiceAgent *other = g_object_get_data (G_OBJECT (agent), "other-agent"); NiceAgent *other = g_object_get_data (G_OBJECT (agent), "other-agent");
const gchar *ufrag = NULL, *password = NULL; gchar *ufrag = NULL, *password = NULL;
GSList *cands; GSList *cands, *i;
guint id, other_id; guint id, other_id;
gpointer tmp; gpointer tmp;
...@@ -109,11 +109,17 @@ static void cb_candidate_gathering_done(NiceAgent *agent, guint stream_id, gpoin ...@@ -109,11 +109,17 @@ static void cb_candidate_gathering_done(NiceAgent *agent, guint stream_id, gpoin
nice_agent_get_local_credentials(agent, id, &ufrag, &password); nice_agent_get_local_credentials(agent, id, &ufrag, &password);
nice_agent_set_remote_credentials (other, nice_agent_set_remote_credentials (other,
other_id, ufrag, password); other_id, ufrag, password);
g_free (ufrag);
g_free (password);
cands = nice_agent_get_local_candidates(agent, id, 1); cands = nice_agent_get_local_candidates(agent, id, 1);
g_assert (cands != NULL); g_assert (cands != NULL);
nice_agent_set_remote_candidates (other, other_id, 1, cands); nice_agent_set_remote_candidates (other, other_id, 1, cands);
for (i = cands; i; i = i->next)
nice_candidate_free ((NiceCandidate *) i->data);
g_slist_free (cands);
} }
......
...@@ -49,7 +49,7 @@ main (void) ...@@ -49,7 +49,7 @@ main (void)
NiceAgent *agent; NiceAgent *agent;
NiceAddress addr_local, addr_remote; NiceAddress addr_local, addr_remote;
NiceCandidate *candidate; NiceCandidate *candidate;
GSList *candidates; GSList *candidates, *i;
guint stream_id; guint stream_id;
nice_address_init (&addr_local); nice_address_init (&addr_local);
...@@ -86,6 +86,8 @@ main (void) ...@@ -86,6 +86,8 @@ main (void)
nice_address_set_port (&(candidate->addr), 1); nice_address_set_port (&(candidate->addr), 1);
g_assert (nice_address_equal (&(candidate->addr), &addr_local)); g_assert (nice_address_equal (&(candidate->addr), &addr_local));
g_assert (strncmp (candidate->foundation, "1", 1) == 0); g_assert (strncmp (candidate->foundation, "1", 1) == 0);
for (i = candidates; i; i = i->next)
nice_candidate_free ((NiceCandidate *) i->data);
g_slist_free (candidates); g_slist_free (candidates);
/* clean up */ /* clean up */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment