Fix Memory Leaks, Synchronisation in Processes, and Refactoring #37
@@ -45,7 +45,7 @@ static unsigned syscall_tell (int fd);
|
|||||||
static void syscall_close (int fd);
|
static void syscall_close (int fd);
|
||||||
|
|
||||||
static struct open_file *fd_get_file (int fd);
|
static struct open_file *fd_get_file (int fd);
|
||||||
static void *validate_user_pointer (const void *ptr, size_t size);
|
static void validate_user_pointer (const void *ptr, size_t size);
|
||||||
|
|
||||||
/* A struct defining a syscall_function pointer along with its arity. */
|
/* A struct defining a syscall_function pointer along with its arity. */
|
||||||
typedef struct
|
typedef struct
|
||||||
@@ -401,7 +401,7 @@ fd_get_file (int fd)
|
|||||||
fully contained within user virtual memory. Kills the thread (by calling
|
fully contained within user virtual memory. Kills the thread (by calling
|
||||||
thread_exit) if the memory is invalid. Otherwise, returns the PTR given.
|
thread_exit) if the memory is invalid. Otherwise, returns the PTR given.
|
||||||
If the size is 0, the function does no checks and returns PTR.*/
|
If the size is 0, the function does no checks and returns PTR.*/
|
||||||
static void *
|
static void
|
||||||
validate_user_pointer (const void *ptr, size_t size)
|
validate_user_pointer (const void *ptr, size_t size)
|
||||||
{
|
{
|
||||||
if (size > 0 && (ptr == NULL ||
|
if (size > 0 && (ptr == NULL ||
|
||||||
@@ -409,6 +409,4 @@ validate_user_pointer (const void *ptr, size_t size)
|
|||||||
!is_user_vaddr (ptr + size - 1) ||
|
!is_user_vaddr (ptr + size - 1) ||
|
||||||
pagedir_get_page (thread_current()->pagedir, ptr) == NULL))
|
pagedir_get_page (thread_current()->pagedir, ptr) == NULL))
|
||||||
thread_exit ();
|
thread_exit ();
|
||||||
|
|
||||||
return (void *) ptr;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user