diff --git a/src/lexer/lexer.c b/src/lexer/lexer.c index 9a7166e..374cd95 100644 --- a/src/lexer/lexer.c +++ b/src/lexer/lexer.c @@ -40,7 +40,7 @@ void msh_lexer_push_item(msh_lexer *lexer, msh_lexer_item_type type, char *buf, }; void msh_lexer_parse(msh_lexer *lexer, char *buf, SIZE_TYPE sz) { - int i = 0, n = 0, last = 0; + int i = 0, n = 0, j = 0; char *cur_word_buf = msh_callocate(1024, sizeof(char)); @@ -91,11 +91,13 @@ void msh_lexer_parse(msh_lexer *lexer, char *buf, SIZE_TYPE sz) { break; } if (do_clear) { - msh_deallocate(cur_word_buf); - cur_word_buf = msh_callocate(1024, sizeof(char)); + for (j = 0; j < 1024; j++) { + cur_word_buf[j++] = 0; + } n = 0; } } + msh_deallocate(cur_word_buf); } void msh_lexer_execute(msh_lexer *lexer) { diff --git a/src/system/linux/linux.c b/src/system/linux/linux.c index 0c6425d..287a6db 100644 --- a/src/system/linux/linux.c +++ b/src/system/linux/linux.c @@ -99,7 +99,11 @@ 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); +}; void msh_file_read(msh_file *file, char *ptr, SIZE_TYPE n) { SYSCALL(read, file->fd, ptr, n); diff --git a/src/util/string.c b/src/util/string.c index db476df..3652673 100644 --- a/src/util/string.c +++ b/src/util/string.c @@ -41,10 +41,10 @@ void msh_str_copy_strs(char *dst, ...) { } n += i; } + va_end(va); }; void msh_str_copy_str(char *dst, char *src) { while ((*dst++ = *src++)) ; - *dst++ = '\0'; };