From b0c1923d44ab971f77401ad9066144e3c60f379d Mon Sep 17 00:00:00 2001 From: Themis Demetriades Date: Wed, 6 Nov 2024 12:28:58 +0000 Subject: [PATCH] Update stack argument initialization behaviour to terminate creation of process on failing memory allocations --- src/userprog/process.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/userprog/process.c b/src/userprog/process.c index aaac9ee..7f38374 100644 --- a/src/userprog/process.c +++ b/src/userprog/process.c @@ -106,7 +106,15 @@ start_process (void *file_name_) push_to_stack (&if_.esp, arg, (strlen (arg) + 1) * sizeof (char)); struct arg_elem *arg_elem = malloc (sizeof (struct arg_elem)); - ASSERT (arg_elem != NULL); + if (arg_elem == NULL) + { + printf("ERROR: Couldn't allocate argument pointer memory for %s!\n", + file_name); + palloc_free_page (file_name_); + if (success) process_exit (); + thread_exit (); + } + arg_elem->arg = arg; list_push_front (&arg_list, &arg_elem->elem);