From: Philip Withnall Date: Tue, 31 Jan 2017 10:04:49 +0000 (+0000) Subject: connection: Fix an LSM label memory leak on an error handling path X-Git-Tag: dbus-1.12.0~282 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=65e489287a84a05c634342e23bd93c2e9ba52a5a;p=platform%2Fupstream%2Fdbus.git connection: Fix an LSM label memory leak on an error handling path 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 --- 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; }