From 65e489287a84a05c634342e23bd93c2e9ba52a5a Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 31 Jan 2017 10:04:49 +0000 Subject: [PATCH] connection: Fix an LSM label memory leak on an error handling path MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This is almost certainly not going to make a difference, as it’s on the OOM handling path; but the fewer leaks the better. Coverity ID: 141058 Bug: https://bugs.freedesktop.org/show_bug.cgi?id=99612 Reviewed-by: Simon McVittie --- bus/connection.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bus/connection.c b/bus/connection.c index dd02ccd..5144218 100644 --- a/bus/connection.c +++ b/bus/connection.c @@ -584,7 +584,7 @@ cache_peer_loginfo_string (BusConnectionData *d, DBusString loginfo_buf; unsigned long uid; unsigned long pid; - char *windows_sid, *security_label; + char *windows_sid = NULL, *security_label = NULL; dbus_bool_t prev_added; if (!_dbus_string_init (&loginfo_buf)) @@ -630,6 +630,7 @@ cache_peer_loginfo_string (BusConnectionData *d, did_append = _dbus_string_append_printf (&loginfo_buf, "sid=\"%s\"", windows_sid); dbus_free (windows_sid); + windows_sid = NULL; if (!did_append) goto oom; else @@ -649,6 +650,7 @@ cache_peer_loginfo_string (BusConnectionData *d, did_append = _dbus_string_append_printf (&loginfo_buf, "label=\"%s\"", security_label); dbus_free (security_label); + security_label = NULL; if (!did_append) goto oom; else @@ -663,6 +665,11 @@ cache_peer_loginfo_string (BusConnectionData *d, return TRUE; oom: _dbus_string_free (&loginfo_buf); + if (security_label != NULL) + dbus_free (security_label); + if (windows_sid != NULL) + dbus_free (windows_sid); + return FALSE; } -- 2.7.4