summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Redaelli <timothy@redaelli.eu>2011-03-31 16:11:54 (GMT)
committerYouness Alaoui <youness.alaoui@collabora.co.uk>2011-03-31 23:22:51 (GMT)
commit6816d2d52a95116c416e722636f0cbfa8923ffde (patch)
tree10cd1c7be28bc339c5ff2d942c6ff9435e9046e3
parent17f2117b49aecf015f54d4443617da89f7d684d6 (diff)
downloadlibnice-6816d2d52a95116c416e722636f0cbfa8923ffde.tar.gz
libnice-6816d2d52a95116c416e722636f0cbfa8923ffde.tar.xz
Fix a (possible) memory leak in nice_turn_socket_new and in a test
-rw-r--r--socket/turn.c4
-rw-r--r--tests/test-pseudotcp.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/socket/turn.c b/socket/turn.c
index 2f30089..4d6fad8 100644
--- a/socket/turn.c
+++ b/socket/turn.c
@@ -166,13 +166,15 @@ nice_turn_socket_new (NiceAgent *agent, NiceAddress *addr,
gchar *username, gchar *password,
NiceTurnSocketCompatibility compatibility)
{
- TurnPriv *priv = g_new0 (TurnPriv, 1);
+ TurnPriv *priv;
NiceSocket *sock = g_slice_new0 (NiceSocket);
if (!sock) {
return NULL;
}
+ priv = g_new0 (TurnPriv, 1);
+
if (compatibility == NICE_TURN_SOCKET_COMPATIBILITY_DRAFT9 ||
compatibility == NICE_TURN_SOCKET_COMPATIBILITY_RFC5766) {
stun_agent_init (&priv->agent, STUN_ALL_KNOWN_ATTRIBUTES,
diff --git a/tests/test-pseudotcp.c b/tests/test-pseudotcp.c
index 92cec3f..363fcde 100644
--- a/tests/test-pseudotcp.c
+++ b/tests/test-pseudotcp.c
@@ -174,7 +174,7 @@ static gboolean notify_packet (gpointer user_data)
static PseudoTcpWriteResult write (PseudoTcpSocket *sock,
const gchar *buffer, guint32 len, gpointer user_data)
{
- struct notify_data *data = g_new0 (struct notify_data,1);
+ struct notify_data *data;
PseudoTcpState state;
int drop_rate = rand () % 100;
g_object_get (sock, "state", &state, NULL);
@@ -184,6 +184,8 @@ static PseudoTcpWriteResult write (PseudoTcpSocket *sock,
return WR_SUCCESS;
}
+ data = g_new0 (struct notify_data,1);
+
g_debug ("Socket %p(%d) Writing : %d bytes", sock, state, len);
data->buffer = g_malloc (len);