Commit 305ce1a9 authored by Olivier Crête's avatar Olivier Crête

discovery: Clean up error handling in discovery_add_local_host_candidate

parent 29d993b8
...@@ -459,7 +459,6 @@ NiceCandidate *discovery_add_local_host_candidate ( ...@@ -459,7 +459,6 @@ NiceCandidate *discovery_add_local_host_candidate (
Component *component; Component *component;
Stream *stream; Stream *stream;
NiceSocket *udp_socket = NULL; NiceSocket *udp_socket = NULL;
gboolean errors = FALSE;
if (!agent_find_component (agent, stream_id, component_id, &stream, &component)) if (!agent_find_component (agent, stream_id, component_id, &stream, &component))
return NULL; return NULL;
...@@ -483,8 +482,9 @@ NiceCandidate *discovery_add_local_host_candidate ( ...@@ -483,8 +482,9 @@ NiceCandidate *discovery_add_local_host_candidate (
/* note: candidate username and password are left NULL as stream /* note: candidate username and password are left NULL as stream
level ufrag/password are used */ level ufrag/password are used */
udp_socket = nice_udp_bsd_socket_new (address); udp_socket = nice_udp_bsd_socket_new (address);
if (udp_socket) { if (!udp_socket)
gboolean result; goto errors;
_priv_set_socket_tos (agent, udp_socket, stream->tos); _priv_set_socket_tos (agent, udp_socket, stream->tos);
agent_attach_stream_component_socket (agent, stream, agent_attach_stream_component_socket (agent, stream,
...@@ -494,29 +494,19 @@ NiceCandidate *discovery_add_local_host_candidate ( ...@@ -494,29 +494,19 @@ NiceCandidate *discovery_add_local_host_candidate (
candidate->addr = udp_socket->addr; candidate->addr = udp_socket->addr;
candidate->base_addr = udp_socket->addr; candidate->base_addr = udp_socket->addr;
result = priv_add_local_candidate_pruned (component, candidate); if (!priv_add_local_candidate_pruned (component, candidate))
goto errors;
if (result == TRUE) {
component->sockets = g_slist_append (component->sockets, udp_socket); component->sockets = g_slist_append (component->sockets, udp_socket);
agent_signal_new_candidate (agent, candidate); agent_signal_new_candidate (agent, candidate);
} else {
/* error: duplicate candidates */
errors = TRUE;
}
} else {
/* error: socket new */
errors = TRUE;
}
/* clean up after errors */ return candidate;
if (errors) {
if (candidate) errors:
nice_candidate_free (candidate), candidate = NULL; nice_candidate_free (candidate);
if (udp_socket) if (udp_socket)
nice_socket_free (udp_socket); nice_socket_free (udp_socket);
} return NULL;
return candidate;
} }
/* /*
......
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