[Spice-devel] [spice-gtk 1/2] sasl: Fix memory leaks in spice_channel_perform_auth_sasl()
Christophe Fergeau
cfergeau at redhat.com
Wed Oct 16 17:39:09 CEST 2013
While looking at the SASL code, I noticed some memory leaks.
---
gtk/spice-channel.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 08418f7..9b2697e 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -1387,7 +1387,9 @@ static gboolean spice_channel_perform_auth_sasl(SpiceChannel *channel)
SASL_SUCCESS_DATA,
&saslconn);
g_free(localAddr);
+ localAddr = NULL;
g_free(remoteAddr);
+ remoteAddr = NULL;
if (err != SASL_OK) {
g_critical("Failed to create SASL client context: %d (%s)",
@@ -1436,8 +1438,6 @@ static gboolean spice_channel_perform_auth_sasl(SpiceChannel *channel)
spice_channel_read(channel, mechlist, len);
mechlist[len] = '\0';
if (c->has_error) {
- g_free(mechlist);
- mechlist = NULL;
goto error;
}
@@ -1450,11 +1450,11 @@ restart:
&clientout,
&clientoutlen,
&mechname);
+ g_free(mechlist);
+ mechlist = NULL;
if (err != SASL_OK && err != SASL_CONTINUE && err != SASL_INTERACT) {
g_critical("Failed to start SASL negotiation: %d (%s)",
err, sasl_errdetail(saslconn));
- g_free(mechlist);
- mechlist = NULL;
goto error;
}
@@ -1640,6 +1640,10 @@ complete:
return ret;
error:
+ g_free(localAddr);
+ g_free(remoteAddr);
+ g_free(mechlist);
+ g_free(serverin);
g_clear_object(&addr);
if (saslconn)
sasl_dispose(&saslconn);
--
1.8.3.1
More information about the Spice-devel
mailing list