[systemd-devel] [PATCH] sd-bus: fix memory leak in test-bus-chat

Lennart Poettering lennart at poettering.net
Thu May 14 13:41:41 PDT 2015


On Sat, 09.05.15 22:14, Cristian Rodríguez (crrodriguez at opensuse.org) wrote:

> Building with address sanitizer enabled on GCC 5.1.x a memory leak
> is reported because we never close the bus, fix it by using
> cleanup variable attribute.

Thanks! Applied!

> ---
>  src/libsystemd/sd-bus/test-bus-chat.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c
> index 99261fa..1e50dfc 100644
> --- a/src/libsystemd/sd-bus/test-bus-chat.c
> +++ b/src/libsystemd/sd-bus/test-bus-chat.c
> @@ -262,7 +262,7 @@ fail:
>  
>  static void* client1(void*p) {
>          _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
> -        sd_bus *bus = NULL;
> +        _cleanup_bus_close_unref_ sd_bus *bus = NULL;
>          sd_bus_error error = SD_BUS_ERROR_NULL;
>          const char *hello;
>          int r;
> @@ -345,8 +345,6 @@ finish:
>                  else
>                          sd_bus_send(bus, q, NULL);
>  
> -                sd_bus_flush(bus);
> -                sd_bus_unref(bus);
>          }
>  
>          sd_bus_error_free(&error);
> -- 
> 2.3.7
> 
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list