From b1a54dd5836019e70a715e04420298092def5f3e Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Mon, 11 Sep 2023 13:17:47 +0200 Subject: [PATCH] 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. --- ft_strdup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) -- 2.30.2