From e946b215cf24efe2d996b84826929f816e689d6d Mon Sep 17 00:00:00 2001 From: starnakin Date: Sat, 1 Jul 2023 11:45:16 +0200 Subject: [PATCH] fix: invalid read --- src/cmd/cmds.c | 2 +- src/env/env.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cmd/cmds.c b/src/cmd/cmds.c index 4679e26..46092b5 100644 --- a/src/cmd/cmds.c +++ b/src/cmd/cmds.c @@ -21,7 +21,7 @@ lst** cmds_init(size_t len) return (NULL); } lst_addback(root, current); - content = malloc(sizeof(cmd)); + content = calloc(sizeof(cmd), 1); if (content == NULL) { lst_clear(root, &free); diff --git a/src/env/env.c b/src/env/env.c index bacfb83..43cdc3a 100644 --- a/src/env/env.c +++ b/src/env/env.c @@ -171,5 +171,6 @@ char **get_env_str(lst** root) current = current->next; i++; } + tab[i] = NULL; return tab; }