diff options
author | kdx <kikoodx@paranoici.org> | 2023-03-15 22:01:40 +0100 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2023-03-15 22:01:40 +0100 |
commit | 935b4cc11ddebd350af76f498416c0a25b83f837 (patch) | |
tree | 7c09bab8b21b0f74983edd47f3e86ffe35892bd8 | |
parent | cef519e1ccf8c73d353c61112f1e4b71fa718fce (diff) | |
download | golem-935b4cc11ddebd350af76f498416c0a25b83f837.tar.gz |
don't crash on empty token list
-rw-r--r-- | main.c | 10 | ||||
-rwxr-xr-x | test.sh | 1 |
2 files changed, 7 insertions, 4 deletions
@@ -32,10 +32,12 @@ main(int argc, char **argv) fclose(file); Token *tokens = lexer(slice); - destroy_duplicates(&tokens, TOK_END); - group_scope(&tokens); - token_print(tokens, 1, 0); - token_destroy(tokens); + if (tokens != NULL) { + destroy_duplicates(&tokens, TOK_END); + group_scope(&tokens); + token_print(tokens, 1, 0); + token_destroy(tokens); + } if (slice.str != NULL) free(slice.str); @@ -1,3 +1,4 @@ #!/bin/sh ./build.sh || exit 1 +./golem /dev/null || exit 1 valgrind ./golem mvp.golem || exit 1 |