From e40794e672668ea20f68b8c892a22758a3392f1c Mon Sep 17 00:00:00 2001 From: sBubshait Date: Fri, 8 Nov 2024 16:48:19 +0000 Subject: [PATCH] Fix Bug in fd_get_file: In case fd not found, then returns NULL, w/ E --- src/userprog/syscall.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/userprog/syscall.c b/src/userprog/syscall.c index 4bd8732..96c099d 100644 --- a/src/userprog/syscall.c +++ b/src/userprog/syscall.c @@ -340,6 +340,9 @@ fd_get_file (int fd) struct hash_elem *e = hash_find (&thread_current ()->open_files, &fake_file_info.elem); + if (e == NULL) + return NULL; + return hash_entry (e, struct open_file, elem); }