From 8cf0d9d94b91d036d44fa02ebe5f6acea594a6d8 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sat, 6 May 2023 14:32:29 +0200 Subject: Added sanitizers for debug compile, fixed memory leak --- Makefile | 4 +++- src/shell.c | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index eb81fe9..fa40765 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,9 @@ CPPFLAGS = -DVERSION=\"${VERSION}\" CFLAGS = -std=c99 -pthread -pedantic -Wall -Wextra \ -Wno-unused-parameter -O3 ${CPPFLAGS} DBGFLAGS = -std=c99 -pthread -pedantic -Wall -Wextra \ - -Wno-unused-parameter -g ${CPPFLAGS} + -Wno-unused-parameter -Wno-unused-function \ + -fsanitize=address -fsanitize=undefined \ + -g3 ${CPPFLAGS} CC = cc diff --git a/src/shell.c b/src/shell.c index 9c3173b..3c19a31 100644 --- a/src/shell.c +++ b/src/shell.c @@ -64,13 +64,13 @@ exec_args(int c, char **v) if (cmd == NULL) { fprintf(stderr, "%s: command not found\n", v[0]); - return; + goto exec_args_end; } args = cmd->parse_args(c-1, &v[1]); if (!args->success) { fprintf(stderr, "usage: %s\n", cmd->usage); - return; + goto exec_args_end; } if (args->scrstdin) { @@ -94,6 +94,8 @@ exec_args(int c, char **v) } else { cmd->exec(args); } + +exec_args_end: free_args(args); } -- cgit v1.3