[systemd-devel] [PATCH] modules-load: fix memory leak
Lennart Poettering
lennart at poettering.net
Mon May 11 14:16:12 PDT 2015
On Mon, 11.05.15 15:37, Cristian RodrÃguez (crrodriguez at opensuse.org) wrote:
Applied! Thanks!
> =================================================================
> ==64281==ERROR: LeakSanitizer: detected memory leaks
>
> Direct leak of 32 byte(s) in 1 object(s) allocated from:
> #0 0x7f623c961c4a in malloc (/usr/lib64/libasan.so.2+0x96c4a)
> #1 0x5651f79ad34e in malloc_multiply (/home/crrodriguez/scm/systemd/systemd-modules-load+0x2134e)
> #2 0x5651f79b02d6 in strjoin (/home/crrodriguez/scm/systemd/systemd-modules-load+0x242d6)
> #3 0x5651f79be1f5 in files_add (/home/crrodriguez/scm/systemd/systemd-modules-load+0x321f5)
> #4 0x5651f79be6a3 in conf_files_list_strv_internal (/home/crrodriguez/scm/systemd/systemd-modules-load+0x326a3)
> #5 0x5651f79bea24 in conf_files_list_nulstr (/home/crrodriguez/scm/systemd/systemd-modules-load+0x32a24)
> #6 0x5651f79ad01a in main (/home/crrodriguez/scm/systemd/systemd-modules-load+0x2101a)
> #7 0x7f623c11586f in __libc_start_main (/lib64/libc.so.6+0x2086f)
>
> SUMMARY: AddressSanitizer: 32 byte(s) leaked in 1 allocation(s).
>
> This happens due to the wrong cleanup attribute is used (free vs strv_free)
> ---
> src/modules-load/modules-load.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c
> index 76e9403..5bbe314 100644
> --- a/src/modules-load/modules-load.c
> +++ b/src/modules-load/modules-load.c
> @@ -252,7 +252,7 @@ int main(int argc, char *argv[]) {
> }
>
> } else {
> - _cleanup_free_ char **files = NULL;
> + _cleanup_strv_free_ char **files = NULL;
> char **fn, **i;
>
> STRV_FOREACH(i, arg_proc_cmdline_modules) {
> --
> 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