aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ali Polatel <alip@exherbo.org> 2021-02-27 12:04:56 +0100
committerAvatar Ali Polatel <alip@exherbo.org> 2021-02-27 15:55:51 +0100
commit1e8bc796f94af3117b0ac16dd81aaab05dd1aad5 (patch)
tree59a35d34b126df2ab95ab7486a84e7841bf8b19d
parentf6a73718bfd232cf6bec20390a0dfa9f866ee2be (diff)
downloadsydbox-1-1e8bc796f94af3117b0ac16dd81aaab05dd1aad5.tar.gz
sydbox-1-1e8bc796f94af3117b0ac16dd81aaab05dd1aad5.tar.xz
clone_process: plug memory leak
Signed-off-by: Ali Polatel <alip@exherbo.org>
-rw-r--r--src/sydbox.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/sydbox.c b/src/sydbox.c
index e6cc1ce..a1a96fb 100644
--- a/src/sydbox.c
+++ b/src/sydbox.c
@@ -374,9 +374,12 @@ static void init_process_data(syd_process_t *current, syd_process_t *parent)
static syd_process_t *clone_process(syd_process_t *p, pid_t cpid)
{
syd_process_t *child;
+ bool new_child;
child = lookup_process(cpid);
- if (child == NULL)
+ new_child = (child == NULL);
+
+ if (new_child)
child = new_thread_or_kill(cpid, post_attach_sigstop);
if (p->new_clone_flags & CLONE_THREAD) {
child->ppid = p->ppid;
@@ -385,7 +388,9 @@ static syd_process_t *clone_process(syd_process_t *p, pid_t cpid)
child->ppid = p->pid;
child->tgid = child->pid;
}
- init_process_data(child, p);
+
+ if (new_child)
+ init_process_data(child, p);
/* clone OK: p->pid <-> cpid */
p->new_clone_flags = 0;