# HG changeset patch # User Richard Laager # Date 1333578336 0 # Node ID cde7e464221bd9881b5ac65a25a4321b3a5537a4 # Parent 88587257d08385b1f00265d8c3907d39cd9bafe2 Reorder create_stream() This eliminates a leak of _params when get_session() or get_participant() fails. diff -r 88587257d083 -r cde7e464221b libpurple/media/backend-fs2.c --- a/libpurple/media/backend-fs2.c Wed Apr 04 22:13:35 2012 +0000 +++ b/libpurple/media/backend-fs2.c Wed Apr 04 22:25:36 2012 +0000 @@ -1767,7 +1767,7 @@ const gchar *stun_ip = purple_network_get_stun_ip(); const gchar *turn_ip = purple_network_get_turn_ip(); guint _num_params = num_params; - GParameter *_params = g_new0(GParameter, num_params + 3); + GParameter *_params; FsStreamDirection type_direction = session_type_to_fs_stream_direction(type); PurpleMediaBackendFs2Session *session; @@ -1779,6 +1779,22 @@ gboolean got_turn_from_prpl = FALSE; int i; + session = get_session(self, sess_id); + + if (session == NULL) { + purple_debug_error("backend-fs2", + "Couldn't find session to create stream.\n"); + return FALSE; + } + + participant = get_participant(self, who); + + if (participant == NULL) { + purple_debug_error("backend-fs2", "Couldn't find " + "participant to create stream.\n"); + return FALSE; + } + for (i = 0 ; i < num_params ; i++) { if (purple_strequal(params[i].name, "relay-info")) { got_turn_from_prpl = TRUE; @@ -1786,6 +1802,7 @@ } } + _params = g_new0(GParameter, num_params + 3); memcpy(_params, params, sizeof(GParameter) * num_params); /* set the controlling mode parameter */ @@ -1840,22 +1857,6 @@ _num_params++; } - session = get_session(self, sess_id); - - if (session == NULL) { - purple_debug_error("backend-fs2", - "Couldn't find session to create stream.\n"); - return FALSE; - } - - participant = get_participant(self, who); - - if (participant == NULL) { - purple_debug_error("backend-fs2", "Couldn't find " - "participant to create stream.\n"); - return FALSE; - } - fsstream = fs_session_new_stream(session->session, participant, initiator == TRUE ? type_direction : (type_direction & FS_DIRECTION_RECV), transmitter,