From 64da29227e358350d247b3c9f094bb4e46819600 Mon Sep 17 00:00:00 2001 From: guamss Date: Sun, 2 Jul 2023 16:29:35 +0200 Subject: [PATCH] =?UTF-8?q?(fix):=20fuite=20de=20m=C3=A9moire?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/exec/exec.c | 4 ++-- src/input/input.c | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/exec/exec.c b/src/exec/exec.c index e25b007..c291681 100644 --- a/src/exec/exec.c +++ b/src/exec/exec.c @@ -13,7 +13,7 @@ int len(void** list) { int index; - for (index = 0; list[index]!=NULL; index++); + for (index = 0; list[index]!=NULL; index++); return index; } @@ -71,7 +71,7 @@ char* get_executable_path(const char* executable, lst** env) tab_free((void**)path_env_splited); return path_file; } - + free(path_file); } tab_free((void**)path_env_splited); diff --git a/src/input/input.c b/src/input/input.c index 6d07ffb..ea38548 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -32,11 +32,13 @@ static char* get_prompt(lst** env) strcpy(cwd, "~"); strcat(cwd, cwd + strlen(home)); } - out = str_merger(8, "[", user, "@", hostname_buff, "]", " > ", cwd, " "); + out = str_merger(8, user, "[", "@", hostname_buff, "]", " > ", cwd, " "); + char* temp = out; if (strcmp(user, "root") == 0) - out = str_merger(2, out, "# "); + out = str_merger(2, "# ", out); else - out = str_merger(2, out, "$ "); + out = str_merger(2, "$ ", out); + free(temp); return out; }