anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0318-sd-bus-fix-memory-leak-in-test-bus-chat.patch

803fb7
From 68550741351080ab8458d54a6900b2b6ea1ef511 Mon Sep 17 00:00:00 2001
803fb7
From: =?UTF-8?q?Cristian=20Rodr=C3=ADguez?= <crrodriguez@opensuse.org>
803fb7
Date: Sat, 9 May 2015 22:14:09 -0300
803fb7
Subject: [PATCH] sd-bus: fix memory leak in test-bus-chat
803fb7
803fb7
Building with address sanitizer enabled on GCC 5.1.x a memory leak
803fb7
is reported because we never close the bus, fix it by using
803fb7
cleanup variable attribute.
803fb7
803fb7
Cherry-picked from: 2f50a2d55bf0a8b5959a6864ae1b39e7e9e0ce08
803fb7
Related: #1331667
803fb7
---
803fb7
 src/libsystemd/sd-bus/test-bus-chat.c | 4 +---
803fb7
 1 file changed, 1 insertion(+), 3 deletions(-)
803fb7
803fb7
diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c
803fb7
index 8625ee6d8..a80aaaeef 100644
803fb7
--- a/src/libsystemd/sd-bus/test-bus-chat.c
803fb7
+++ b/src/libsystemd/sd-bus/test-bus-chat.c
803fb7
@@ -264,7 +264,7 @@ fail:
803fb7
 
803fb7
 static void* client1(void*p) {
803fb7
         _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
803fb7
-        sd_bus *bus = NULL;
803fb7
+        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
803fb7
         sd_bus_error error = SD_BUS_ERROR_NULL;
803fb7
         const char *hello;
803fb7
         int r;
803fb7
@@ -347,8 +347,6 @@ finish:
803fb7
                 else
803fb7
                         sd_bus_send(bus, q, NULL);
803fb7
 
803fb7
-                sd_bus_flush(bus);
803fb7
-                sd_bus_unref(bus);
803fb7
         }
803fb7
 
803fb7
         sd_bus_error_free(&error);