Mercurial > pidgin
comparison libpurple/media/backend-fs2.c @ 32764:cde7e464221b
Reorder create_stream()
This eliminates a leak of _params when get_session() or
get_participant() fails.
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Wed, 04 Apr 2012 22:25:36 +0000 |
parents | 88587257d083 |
children | 60bd913072f7 |
comparison
equal
deleted
inserted
replaced
32763:88587257d083 | 32764:cde7e464221b |
---|---|
1765 GError *err = NULL; | 1765 GError *err = NULL; |
1766 FsStream *fsstream = NULL; | 1766 FsStream *fsstream = NULL; |
1767 const gchar *stun_ip = purple_network_get_stun_ip(); | 1767 const gchar *stun_ip = purple_network_get_stun_ip(); |
1768 const gchar *turn_ip = purple_network_get_turn_ip(); | 1768 const gchar *turn_ip = purple_network_get_turn_ip(); |
1769 guint _num_params = num_params; | 1769 guint _num_params = num_params; |
1770 GParameter *_params = g_new0(GParameter, num_params + 3); | 1770 GParameter *_params; |
1771 FsStreamDirection type_direction = | 1771 FsStreamDirection type_direction = |
1772 session_type_to_fs_stream_direction(type); | 1772 session_type_to_fs_stream_direction(type); |
1773 PurpleMediaBackendFs2Session *session; | 1773 PurpleMediaBackendFs2Session *session; |
1774 PurpleMediaBackendFs2Stream *stream; | 1774 PurpleMediaBackendFs2Stream *stream; |
1775 FsParticipant *participant; | 1775 FsParticipant *participant; |
1777 we need to do this to allow them to override when using non-standard | 1777 we need to do this to allow them to override when using non-standard |
1778 TURN modes, like Google f.ex. */ | 1778 TURN modes, like Google f.ex. */ |
1779 gboolean got_turn_from_prpl = FALSE; | 1779 gboolean got_turn_from_prpl = FALSE; |
1780 int i; | 1780 int i; |
1781 | 1781 |
1782 session = get_session(self, sess_id); | |
1783 | |
1784 if (session == NULL) { | |
1785 purple_debug_error("backend-fs2", | |
1786 "Couldn't find session to create stream.\n"); | |
1787 return FALSE; | |
1788 } | |
1789 | |
1790 participant = get_participant(self, who); | |
1791 | |
1792 if (participant == NULL) { | |
1793 purple_debug_error("backend-fs2", "Couldn't find " | |
1794 "participant to create stream.\n"); | |
1795 return FALSE; | |
1796 } | |
1797 | |
1782 for (i = 0 ; i < num_params ; i++) { | 1798 for (i = 0 ; i < num_params ; i++) { |
1783 if (purple_strequal(params[i].name, "relay-info")) { | 1799 if (purple_strequal(params[i].name, "relay-info")) { |
1784 got_turn_from_prpl = TRUE; | 1800 got_turn_from_prpl = TRUE; |
1785 break; | 1801 break; |
1786 } | 1802 } |
1787 } | 1803 } |
1788 | 1804 |
1805 _params = g_new0(GParameter, num_params + 3); | |
1789 memcpy(_params, params, sizeof(GParameter) * num_params); | 1806 memcpy(_params, params, sizeof(GParameter) * num_params); |
1790 | 1807 |
1791 /* set the controlling mode parameter */ | 1808 /* set the controlling mode parameter */ |
1792 _params[_num_params].name = "controlling-mode"; | 1809 _params[_num_params].name = "controlling-mode"; |
1793 g_value_init(&_params[_num_params].value, G_TYPE_BOOLEAN); | 1810 g_value_init(&_params[_num_params].value, G_TYPE_BOOLEAN); |
1836 G_TYPE_VALUE_ARRAY); | 1853 G_TYPE_VALUE_ARRAY); |
1837 g_value_set_boxed(&_params[_num_params].value, | 1854 g_value_set_boxed(&_params[_num_params].value, |
1838 relay_info); | 1855 relay_info); |
1839 g_value_array_free(relay_info); | 1856 g_value_array_free(relay_info); |
1840 _num_params++; | 1857 _num_params++; |
1841 } | |
1842 | |
1843 session = get_session(self, sess_id); | |
1844 | |
1845 if (session == NULL) { | |
1846 purple_debug_error("backend-fs2", | |
1847 "Couldn't find session to create stream.\n"); | |
1848 return FALSE; | |
1849 } | |
1850 | |
1851 participant = get_participant(self, who); | |
1852 | |
1853 if (participant == NULL) { | |
1854 purple_debug_error("backend-fs2", "Couldn't find " | |
1855 "participant to create stream.\n"); | |
1856 return FALSE; | |
1857 } | 1858 } |
1858 | 1859 |
1859 fsstream = fs_session_new_stream(session->session, participant, | 1860 fsstream = fs_session_new_stream(session->session, participant, |
1860 initiator == TRUE ? type_direction : | 1861 initiator == TRUE ? type_direction : |
1861 (type_direction & FS_DIRECTION_RECV), transmitter, | 1862 (type_direction & FS_DIRECTION_RECV), transmitter, |