[Spice-devel] [PATCH spice 2/2] sasl: small refactoring, check memcheck != NULL

Marc-André Lureau marcandre.lureau at gmail.com
Tue Mar 20 12:30:51 PDT 2012


---
 server/reds.c |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/server/reds.c b/server/reds.c
index b5d185e..30e3ac0 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -2480,9 +2480,7 @@ static void reds_start_auth_sasl(RedLinkInfo *link)
         if (err != SASL_OK) {
             red_printf("cannot set SASL external SSF %d (%s)",
                        err, sasl_errstring(err, NULL, NULL));
-            sasl_dispose(&sasl->conn);
-            sasl->conn = NULL;
-            goto error;
+            goto error_dispose;
         }
     } else {
         sasl->wantSSF = 1;
@@ -2510,9 +2508,7 @@ static void reds_start_auth_sasl(RedLinkInfo *link)
     if (err != SASL_OK) {
         red_printf("cannot set SASL security props %d (%s)",
                    err, sasl_errstring(err, NULL, NULL));
-        sasl_dispose(&sasl->conn);
-        sasl->conn = NULL;
-        goto error;
+        goto error_dispose;
     }
 
     err = sasl_listmech(sasl->conn,
@@ -2523,13 +2519,12 @@ static void reds_start_auth_sasl(RedLinkInfo *link)
                         &mechlist,
                         NULL,
                         NULL);
-    if (err != SASL_OK) {
+    if (err != SASL_OK || mechlist == NULL) {
         red_printf("cannot list SASL mechanisms %d (%s)",
                    err, sasl_errdetail(sasl->conn));
-        sasl_dispose(&sasl->conn);
-        sasl->conn = NULL;
-        goto error;
+        goto error_dispose;
     }
+
     red_printf("Available mechanisms for client: '%s'", mechlist);
 
     sasl->mechlist = spice_strdup(mechlist);
@@ -2549,6 +2544,9 @@ static void reds_start_auth_sasl(RedLinkInfo *link)
 
     return;
 
+error_dispose:
+    sasl_dispose(&sasl->conn);
+    sasl->conn = NULL;
 error:
     reds_link_free(link);
     return;
-- 
1.7.7.6



More information about the Spice-devel mailing list