diff --git a/test/unittest/modules/context_unittest.cpp b/test/unittest/modules/context_unittest.cpp index c163effb2..0286ee9c0 100755 --- a/test/unittest/modules/context_unittest.cpp +++ b/test/unittest/modules/context_unittest.cpp @@ -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 diff --git a/test/unittest/seccomp/seccomp_unittest.cpp b/test/unittest/seccomp/seccomp_unittest.cpp index 760e39226..b2cdbfe4c 100644 --- a/test/unittest/seccomp/seccomp_unittest.cpp +++ b/test/unittest/seccomp/seccomp_unittest.cpp @@ -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;