[systemd-devel] [PATCH 1/6] journal: fix memleak, call set_free before return

Michal Schmidt mschmidt at redhat.com
Thu Oct 25 16:08:26 PDT 2012


Dne 25.10.2012 16:16, Michal Sekletar napsal(a):
> ---
>   src/journal/coredumpctl.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c
> index 5c442ff..d15a31e 100644
> --- a/src/journal/coredumpctl.c
> +++ b/src/journal/coredumpctl.c
> @@ -58,6 +58,7 @@ static Set *new_matches(void) {
>           if (!tmp) {
>                   log_oom();
>                   set_clear_free(set);
> +                set_free(set);
>                   return NULL;
>           }
>

OK, set_free(set) is correct here. The set is still empty, so calling 
set_clear_free(set) is pointless. Remove it.

> @@ -66,6 +67,7 @@ static Set *new_matches(void) {
>                   log_error("failed to add to set: %s", strerror(-r));
>                   free(tmp);
>                   set_clear_free(set);
> +                set_free(set);
>                   return NULL;
>           }
>
>

Same here.

Michal


More information about the systemd-devel mailing list