diff --git a/userprog/syscall_filesize.c b/userprog/syscall_filesize.c index aff7fe7a80c3666fd4d69ac8d7a35aaab5eb06aa..7247c5ccaf8958f4dd1864a337ac709025bde131 100644 --- a/userprog/syscall_filesize.c +++ b/userprog/syscall_filesize.c @@ -13,6 +13,7 @@ void syscall_filesize(struct intr_frame *f) { struct file *file = get_associated_file_pointer(file_descriptor); if (file == NULL) { // Checking if file is empty or non-existent f->eax -1; // Returning failure state + return; } // Using the file_length function in file.h to get the length and store it int size = file_length(file); diff --git a/userprog/syscall_seek.c b/userprog/syscall_seek.c index 9a665a14a14c72a36a04c1fea7b5766130fdf09b..e016d6fc253643e6ba316fc48389d78cf222ffe1 100644 --- a/userprog/syscall_seek.c +++ b/userprog/syscall_seek.c @@ -17,6 +17,9 @@ void syscall_seek(struct intr_frame *f) { // pop off second int argument from interrupt frame unsigned file_pos = *((unsigned*)((int*)f->esp + 2)); struct file *file = get_associated_file_pointer(file_descriptor); + if (file == NULL) { // Checking if file is empty or non-existent + return; + } // Seek through the file file_seek(file, file_pos); }