From 66ffa0b3a8f671718ce3a651426425d53cb09d80 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 18 Jan 2012 10:38:04 +0100 Subject: [PATCH 10/52] vnc-auth-sasl: fix a memory leak RH-Author: Markus Armbruster Message-id: <1326883126-22053-11-git-send-email-armbru@redhat.com> Patchwork-id: 36575 O-Subject: [RHEL-6.3 PATCH qemu-kvm 10/52] vnc-auth-sasl: fix a memory leak Bugzilla: 758194 RH-Acked-by: Miroslav Rezanina RH-Acked-by: Laszlo Ersek RH-Acked-by: Amit Shah From: Blue Swirl Fix a memory leak reported by cppcheck: [/src/qemu/ui/vnc-auth-sasl.c:448]: (error) Memory leak: mechname Signed-off-by: Blue Swirl (cherry picked from commit 8ce7d35273352ebe19c871e6b32a52db77fa08c3) Signed-off-by: Markus Armbruster --- vnc-auth-sasl.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) Signed-off-by: Michal Novotny --- vnc-auth-sasl.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diff --git a/vnc-auth-sasl.c b/vnc-auth-sasl.c index acaac0c..6ceb3e9 100644 --- a/vnc-auth-sasl.c +++ b/vnc-auth-sasl.c @@ -443,22 +443,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; } } @@ -468,6 +465,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) -- 1.7.7.5