From bbbdfc44dabceb41e2e5b9ce18695a37ef8a0288 Mon Sep 17 00:00:00 2001 From: Albert S Date: Sun, 29 May 2022 19:25:53 +0200 Subject: [PATCH] exile.hpp: do_clone(): free stack memory --- exile.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/exile.hpp b/exile.hpp index a2463de..03c9702 100644 --- a/exile.hpp +++ b/exile.hpp @@ -100,6 +100,7 @@ inline int do_clone(int (*clonefn)(void *), void *launcharg) } size_t size = rlimit.rlim_cur; char *stack = (char *) calloc(1, size); + char *stackbegin = stack; if(stack == NULL) { EXILE_LOG_ERROR("Failed to allocate stack memory for child\n"); @@ -110,6 +111,7 @@ inline int do_clone(int (*clonefn)(void *), void *launcharg) ret = clone(clonefn, stack, 17 /* SIGCHLD */, launcharg); int status = 0; waitpid(ret, &status, __WALL); + free(stackbegin); if(WIFEXITED(status)) { return WEXITSTATUS(status);