librc: fix potential use-after-free

Both 'pkg' and 'local' are referenced within list,
so we can't free them yet.

Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Sam James 2022-03-31 07:11:50 +01:00 committed by William Hubbs
parent c4f8b1559c
commit 1afcc37803

View File

@ -947,11 +947,9 @@ rc_services_in_runlevel(const char *runlevel)
#ifdef RC_PKG_INITDIR
TAILQ_CONCAT(list, pkg, entries);
free(pkg);
#endif
#ifdef RC_LOCAL_INITDIR
TAILQ_CONCAT(list, local, entries);
free(local);
#endif
return list;
}