From f40ce5e741300edecfeef45220f4695424d05e39 Mon Sep 17 00:00:00 2001 From: Gautham Kuppuswamy Date: Tue, 18 Jun 2024 12:19:10 -0400 Subject: [PATCH] Appending the copied env string with NULL character for correct behavior Signed-off-by: Gautham Kuppuswamy --- src/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.c b/src/main.c index d9259f9..c6a985c 100644 --- a/src/main.c +++ b/src/main.c @@ -896,6 +896,7 @@ static const char **env_comp(zl_comp_t *comp) { char *thisEnv = *env; char *aux = malloc(strlen(thisEnv) + 1); strncpy(aux, thisEnv, strlen(thisEnv)); + aux[strlen(thisEnv)] = '\0'; trimRight(aux, strlen(aux)); env_comp[i] = aux; i++;