fix: wrong check for malloc failure leads to failing tests

This commit is contained in:
Khaïs COLIN 2025-03-10 15:06:01 +01:00
parent 4fa56b45b6
commit 42bccd0a06
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */ /* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/04 12:07:53 by khais #+# #+# */ /* Created: 2025/03/04 12:07:53 by khais #+# #+# */
/* Updated: 2025/03/09 14:29:36 by khais ### ########.fr */ /* Updated: 2025/03/10 15:05:51 by khais ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -32,9 +32,11 @@ t_wordlist *wordlist_copy(const t_wordlist *wordlist)
while (wordlist != NULL) while (wordlist != NULL)
{ {
if (wordlist->next != NULL) if (wordlist->next != NULL)
{
current->next = ft_calloc(1, sizeof(t_wordlist)); current->next = ft_calloc(1, sizeof(t_wordlist));
if (current->next == NULL) if (current->next == NULL)
return (wordlist_destroy(outlist), NULL); return (wordlist_destroy(outlist), NULL);
}
wordlist = wordlist->next; wordlist = wordlist->next;
current = current->next; current = current->next;
if (wordlist == NULL) if (wordlist == NULL)