librc: fix memory leak in rc_services_in_runlevel_stacked

Seen on running rc-status.

```
=================================================================
==14636==ERROR: LeakSanitizer: detected memory leaks

Indirect leak of 72 byte(s) in 3 object(s) allocated from:
    #0 0x7f443412dcb7 in __interceptor_malloc /usr/src/debug/sys-devel/gcc-11.2.1_p20220312/gcc-11-20220312/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x7f443400c727 in xmalloc ../src/includes/helpers.h:64
    #2 0x7f443400d1f4 in rc_stringlist_add ../src/librc/librc-stringlist.c:32
    #3 0x7f4433fecc34 in get_runlevel_chain ../src/librc/librc.c:390
    #4 0x7f4433fedc00 in rc_runlevel_stacks ../src/librc/librc.c:519
    #5 0x7f4433ff1d8e in rc_services_in_runlevel_stacked ../src/librc/librc.c:976
    #6 0x55be0e8f9517 in main ../src/rc/rc-status.c:407
    #7 0x7f44334736cf in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
```

Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Sam James 2022-03-29 07:29:07 +01:00 committed by William Hubbs
parent 3054046e18
commit 14835a2262

View File

@ -979,6 +979,7 @@ rc_services_in_runlevel_stacked(const char *runlevel)
TAILQ_CONCAT(list, sl, entries);
free(sl);
}
rc_stringlist_free(stacks);
return list;
}