From 73a64b2ec3e292411ab42edd126359aa1daa7df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kha=C3=AFs=20COLIN?= Date: Thu, 20 Mar 2025 12:23:54 +0100 Subject: [PATCH] fix potential memory leak in cmdlist_from_wordlist This leak would happen if the alocation of the builder fails. In that case, we don't free our copy of the wordlist --- src/parser/cmdlist/cmdlist.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/parser/cmdlist/cmdlist.c b/src/parser/cmdlist/cmdlist.c index 9676b8c..d5efcc3 100644 --- a/src/parser/cmdlist/cmdlist.c +++ b/src/parser/cmdlist/cmdlist.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/24 17:49:46 by khais #+# #+# */ -/* Updated: 2025/03/19 16:43:14 by khais ### ########.fr */ +/* Updated: 2025/03/20 12:23:39 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -81,7 +81,7 @@ t_cmdlist *cmdlist_from_wordlist(const t_wordlist *wordlist) if (words == NULL) return (NULL); if (setup_cmdlist_builder(&builder, &words) == NULL) - return (NULL); + return (wordlist_destroy(words), NULL); while (builder.error == false && builder.current_word != NULL) { if (match_op(builder.current_word->word) == OP_INVALID)