Commit 6816d2d5 authored by Timothy Redaelli's avatar Timothy Redaelli Committed by Youness Alaoui

Fix a (possible) memory leak in nice_turn_socket_new and in a test

parent 17f2117b
...@@ -166,13 +166,15 @@ nice_turn_socket_new (NiceAgent *agent, NiceAddress *addr, ...@@ -166,13 +166,15 @@ nice_turn_socket_new (NiceAgent *agent, NiceAddress *addr,
gchar *username, gchar *password, gchar *username, gchar *password,
NiceTurnSocketCompatibility compatibility) NiceTurnSocketCompatibility compatibility)
{ {
TurnPriv *priv = g_new0 (TurnPriv, 1); TurnPriv *priv;
NiceSocket *sock = g_slice_new0 (NiceSocket); NiceSocket *sock = g_slice_new0 (NiceSocket);
if (!sock) { if (!sock) {
return NULL; return NULL;
} }
priv = g_new0 (TurnPriv, 1);
if (compatibility == NICE_TURN_SOCKET_COMPATIBILITY_DRAFT9 || if (compatibility == NICE_TURN_SOCKET_COMPATIBILITY_DRAFT9 ||
compatibility == NICE_TURN_SOCKET_COMPATIBILITY_RFC5766) { compatibility == NICE_TURN_SOCKET_COMPATIBILITY_RFC5766) {
stun_agent_init (&priv->agent, STUN_ALL_KNOWN_ATTRIBUTES, stun_agent_init (&priv->agent, STUN_ALL_KNOWN_ATTRIBUTES,
......
...@@ -174,7 +174,7 @@ static gboolean notify_packet (gpointer user_data) ...@@ -174,7 +174,7 @@ static gboolean notify_packet (gpointer user_data)
static PseudoTcpWriteResult write (PseudoTcpSocket *sock, static PseudoTcpWriteResult write (PseudoTcpSocket *sock,
const gchar *buffer, guint32 len, gpointer user_data) const gchar *buffer, guint32 len, gpointer user_data)
{ {
struct notify_data *data = g_new0 (struct notify_data,1); struct notify_data *data;
PseudoTcpState state; PseudoTcpState state;
int drop_rate = rand () % 100; int drop_rate = rand () % 100;
g_object_get (sock, "state", &state, NULL); g_object_get (sock, "state", &state, NULL);
...@@ -184,6 +184,8 @@ static PseudoTcpWriteResult write (PseudoTcpSocket *sock, ...@@ -184,6 +184,8 @@ static PseudoTcpWriteResult write (PseudoTcpSocket *sock,
return WR_SUCCESS; return WR_SUCCESS;
} }
data = g_new0 (struct notify_data,1);
g_debug ("Socket %p(%d) Writing : %d bytes", sock, state, len); g_debug ("Socket %p(%d) Writing : %d bytes", sock, state, len);
data->buffer = g_malloc (len); data->buffer = g_malloc (len);
......
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