diff --git a/src/system/linux/alloc.c b/src/system/linux/alloc.c index 69d497c..1c98631 100644 --- a/src/system/linux/alloc.c +++ b/src/system/linux/alloc.c @@ -107,6 +107,9 @@ void *msh_allocate(SIZE_TYPE size) { }; void msh_deallocate(void *ptr) { + if (ptr == 0) { + return; + } msh_linux_block *block = get_metadata_block(ptr); block->free = 1; if (block->prev && block->prev->free) { diff --git a/src/system/linux/env.c b/src/system/linux/env.c index 22c072c..67d0c03 100644 --- a/src/system/linux/env.c +++ b/src/system/linux/env.c @@ -5,9 +5,9 @@ msh_linux_env_item *env_items = 0; msh_linux_env_item *env_item_tail = 0; void msh_linux_env_map_init() { - msh_file *env_file; - SIZE_TYPE cur; - char *file_buf; + msh_file *env_file = 0; + SIZE_TYPE cur = 0; + char *file_buf = 0; char ch = 1; int counter = 0, i = 0; diff --git a/src/system/linux/linux.c b/src/system/linux/linux.c index 287a6db..5c9537f 100644 --- a/src/system/linux/linux.c +++ b/src/system/linux/linux.c @@ -33,7 +33,6 @@ int msh_execute(char *cmd, char **args) { return 0; } SIZE_TYPE fork = (SIZE_TYPE)SYSCALL(fork, 0); - // int fork = 0; if (fork == 0) { char **env_translated = 0; @@ -52,7 +51,8 @@ int msh_execute(char *cmd, char **args) { int n = 0; char *entry = msh_allocate(item_list->key_len + item_list->value_len + 2); - msh_str_copy_strs(entry, item_list->key, "=", item_list->value, "\0"); + msh_str_copy_strs(entry, item_list->key, "=", item_list->value, "\0", + 0); env_translated[i++] = entry; } item_list = item_list->next; @@ -99,10 +99,10 @@ msh_file *msh_file_open(const char *file) { return f; }; -void msh_file_close(msh_file *file) { - SYSCALL(close, file->fd); +void msh_file_close(msh_file *file) { + SYSCALL(close, file->fd); - msh_deallocate(file); + msh_deallocate(file); }; void msh_file_read(msh_file *file, char *ptr, SIZE_TYPE n) {