fix(wildcard): error detection in wordlist_expand_star

Will help in closing #167
This commit is contained in:
Khaïs COLIN 2025-04-30 14:49:49 +02:00
parent 3ae29cbdf7
commit 04eabf096d
3 changed files with 24 additions and 13 deletions

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* wordlist_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/10 09:51:34 by jguelen #+# #+# */
/* Updated: 2025/03/20 14:43:17 by jguelen ### ########.fr */
/* Updated: 2025/04/30 14:52:32 by kcolin ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,6 +14,7 @@
#include "../worddesc/worddesc.h"
#include <stdlib.h>
#include "../../../libft/libft.h"
#include "../../ft_errno.h"
/*
** Creates a new wordlist composed of only one element. Its next field is NULL
@ -27,18 +28,18 @@ t_wordlist *wordlist_independant_create(t_worddesc *word)
new = ft_calloc(1, sizeof(t_wordlist));
if (!new)
return (NULL);
return (ft_errno(FT_ENOMEM), NULL);
desc_copy = ft_calloc(1, sizeof(t_worddesc));
if (!desc_copy)
return (free(new), NULL);
return (free(new), ft_errno(FT_ENOMEM), NULL);
desc_copy->word = ft_strdup(word->word);
if (!desc_copy->word)
return (free(desc_copy), free(new), NULL);
return (free(desc_copy), free(new), ft_errno(FT_ENOMEM), NULL);
desc_copy->flags = word->flags;
desc_copy->marker = ft_strdup(word->marker);
new->word = desc_copy;
if (!desc_copy->marker && word->marker)
return (wordlist_destroy(new), NULL);
return (wordlist_destroy(new), ft_errno(FT_ENOMEM), NULL);
return (new);
}