diff --git a/kernel/syscall.c b/kernel/syscall.c index f0f5521f..7dfee0c4 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -352,6 +352,13 @@ static int sys_dup(int fd) if (BUILTIN_EXPECT((new_fd >= NR_OPEN) || (fd < 0), 0)) return new_fd; /* in this case fd = errno */ + /* + * free the memory which was allocated in get_fildes() + * cause will link it to another existing memory space + */ + kfree(curr_task->fildes_table[new_fd], sizeof(fildes_t)); + + /* and link it to another existing memory space */ curr_task->fildes_table[new_fd] = curr_task->fildes_table[fd]; curr_task->fildes_table[fd]->count++;