pidgin.2.x.y: 90a5af0a: Reorder create_stream()
rlaager at pidgin.im
rlaager at pidgin.im
Fri Apr 6 00:43:53 EDT 2012
----------------------------------------------------------------------
Revision: 90a5af0a7e4f5d750c4dd418f9f752a59c717182
Parent: 77339cf754801941f39693202daa9bc6af8a5d74
Author: rlaager at pidgin.im
Date: 04/04/12 18:25:36
Branch: im.pidgin.pidgin.2.x.y
URL: http://d.pidgin.im/viewmtn/revision/info/90a5af0a7e4f5d750c4dd418f9f752a59c717182
Changelog:
Reorder create_stream()
This eliminates a leak of _params when get_session() or
get_participant() fails.
Changes against parent 77339cf754801941f39693202daa9bc6af8a5d74
patched libpurple/media/backend-fs2.c
-------------- next part --------------
============================================================
--- libpurple/media/backend-fs2.c fc22a9ee6a858441f44f76f877f008a8e54be160
+++ libpurple/media/backend-fs2.c 2e995e6e3030c0ee13f88f5a0c8d6a47e1446828
@@ -1767,7 +1767,7 @@ create_stream(PurpleMediaBackendFs2 *sel
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 @@ create_stream(PurpleMediaBackendFs2 *sel
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 @@ create_stream(PurpleMediaBackendFs2 *sel
}
}
+ _params = g_new0(GParameter, num_params + 3);
memcpy(_params, params, sizeof(GParameter) * num_params);
/* set the controlling mode parameter */
@@ -1840,22 +1857,6 @@ create_stream(PurpleMediaBackendFs2 *sel
_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,
More information about the Commits
mailing list