]> git.proxmox.com Git - mirror_qemu.git/commitdiff
vnc-auth-sasl: fix a memory leak
authorBlue Swirl <blauwirbel@gmail.com>
Wed, 12 Jan 2011 19:48:56 +0000 (19:48 +0000)
committerBlue Swirl <blauwirbel@gmail.com>
Wed, 12 Jan 2011 19:48:56 +0000 (19:48 +0000)
Fix a memory leak reported by cppcheck:
[/src/qemu/ui/vnc-auth-sasl.c:448]: (error) Memory leak: mechname

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
ui/vnc-auth-sasl.c

index a51ddc8a1863051ec242040e3cc1a1b5bae76c78..17a621a2ba8f57d761289748952b812afbf8f88c 100644 (file)
@@ -444,22 +444,19 @@ static int protocol_client_auth_sasl_mechname(VncState *vs, uint8_t *data, size_
         if (vs->sasl.mechlist[len] != '\0' &&
             vs->sasl.mechlist[len] != ',') {
             VNC_DEBUG("One %d", vs->sasl.mechlist[len]);
-            vnc_client_error(vs);
-            return -1;
+            goto fail;
         }
     } else {
         char *offset = strstr(vs->sasl.mechlist, mechname);
         VNC_DEBUG("Two %p\n", offset);
         if (!offset) {
-            vnc_client_error(vs);
-            return -1;
+            goto fail;
         }
         VNC_DEBUG("Two '%s'\n", offset);
         if (offset[-1] != ',' ||
             (offset[len] != '\0'&&
              offset[len] != ',')) {
-            vnc_client_error(vs);
-            return -1;
+            goto fail;
         }
     }
 
@@ -469,6 +466,11 @@ static int protocol_client_auth_sasl_mechname(VncState *vs, uint8_t *data, size_
     VNC_DEBUG("Validated mechname '%s'\n", mechname);
     vnc_read_when(vs, protocol_client_auth_sasl_start_len, 4);
     return 0;
+
+ fail:
+    vnc_client_error(vs);
+    free(mechname);
+    return -1;
 }
 
 static int protocol_client_auth_sasl_mechname_len(VncState *vs, uint8_t *data, size_t len)