fix: memory leakage in file descriptor allocation
[lunaix-os.git] / lunaix-os / kernel / process / sched.c
index caec0e67cd05acd8d6ea26bf1d828eaed2f35b64..c2a24261dde6c7dc92eba8285b37368209c9a457 100644 (file)
@@ -347,8 +347,10 @@ destroy_process(pid_t pid)
 
     for (size_t i = 0; i < VFS_MAX_FD; i++) {
         struct v_fd* fd = proc->fdtable->fds[i];
-        if (fd)
+        if (fd) {
             vfs_pclose(fd->file, pid);
+            vfs_free_fd(fd);
+        }
     }
 
     vfree(proc->fdtable);