From: Lukas Jiriste Date: Mon, 11 Sep 2023 11:17:47 +0000 (+0200) Subject: This branch will contain functions that don't crash in cases in which the std functio... X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=b1a54dd5836019e70a715e04420298092def5f3e;p=Libft.git This branch will contain functions that don't crash in cases in which the std functions probably crash. This functionality may be useful but is held on separate branch in order to have "pure" std functionality also. --- diff --git a/ft_strdup.c b/ft_strdup.c index d16d5e0..1d5d1b6 100644 --- a/ft_strdup.c +++ b/ft_strdup.c @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/06/17 13:33:49 by ljiriste #+# #+# */ -/* Updated: 2023/08/15 12:52:18 by ljiriste ### ########.fr */ +/* Updated: 2023/09/11 12:37:12 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,6 +18,8 @@ char *ft_strdup(const char *s) char *dest; size_t s_len; + if (s == NULL) + return (NULL); s_len = ft_strlen(s); dest = malloc((s_len + 1) * sizeof(char)); if (dest)