From ba92c07a7577176918348134dd3cca8e92822e1a Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Sat, 18 May 2019 02:00:54 +0200 Subject: [PATCH] Kernel: Make sure to clear FD sets when preparing for a select NULL sets can happen, and we don't want to incorrectly return FDs which aren't in the set too. --- Kernel/Process.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index ea5cd64935..c91d5c1e87 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -1751,9 +1751,9 @@ int Process::sys$select(const Syscall::SC_select_params* params) // FIXME: Return -EINVAL if timeout is invalid. auto transfer_fds = [this, nfds] (fd_set* set, auto& vector) -> int { + vector.clear_with_capacity(); if (!set) return 0; - vector.clear_with_capacity(); auto bitmap = Bitmap::wrap((byte*)set, FD_SETSIZE); for (int i = 0; i < nfds; ++i) { if (bitmap.get(i)) {