!2920 Fix resource leak

Merge pull request !2920 from 杨浩/fixleak
This commit is contained in:
openharmony_ci 2024-06-27 03:31:40 +00:00 committed by Gitee
commit 6b73779901
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 3 additions and 0 deletions

View File

@ -53,6 +53,7 @@ pid_t SubInitFork(int (*childFunc)(const SubInitForkArg *arg), const SubInitFork
int ret = pthread_create(&g_thread, nullptr, ThreadFunc, forkArg);
if (ret != 0) {
printf("Failed to create thread %d \n", errno);
free(forkArg);
return -1;
}
usleep(100); // 100 wait

View File

@ -176,6 +176,7 @@ public:
}
if (setns(fd, CLONE_NEWNS) != 0) {
close(fd);
return false;
}
@ -199,6 +200,7 @@ public:
char *stackTop = stack + stackSize;
pid_t pid = clone(ChildFunc, stackTop, flag | SIGCHLD, nullptr);
if (pid == -1) {
free(stack);
return false;
}
return true;