mirror of
https://gitee.com/openharmony/startup_init
synced 2024-11-27 10:20:46 +00:00
fix leak
Signed-off-by: yh <yanghao236@huawei.com>
This commit is contained in:
parent
b5969e512b
commit
a04a6cfe70
@ -53,6 +53,7 @@ pid_t SubInitFork(int (*childFunc)(const SubInitForkArg *arg), const SubInitFork
|
|||||||
int ret = pthread_create(&g_thread, nullptr, ThreadFunc, forkArg);
|
int ret = pthread_create(&g_thread, nullptr, ThreadFunc, forkArg);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
printf("Failed to create thread %d \n", errno);
|
printf("Failed to create thread %d \n", errno);
|
||||||
|
free(forkArg);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
usleep(100); // 100 wait
|
usleep(100); // 100 wait
|
||||||
|
@ -176,6 +176,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (setns(fd, CLONE_NEWNS) != 0) {
|
if (setns(fd, CLONE_NEWNS) != 0) {
|
||||||
|
close(fd);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,6 +200,7 @@ public:
|
|||||||
char *stackTop = stack + stackSize;
|
char *stackTop = stack + stackSize;
|
||||||
pid_t pid = clone(ChildFunc, stackTop, flag | SIGCHLD, nullptr);
|
pid_t pid = clone(ChildFunc, stackTop, flag | SIGCHLD, nullptr);
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
|
free(stack);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user