diff --git a/libft/src/str/ft_strdup.c b/libft/src/str/ft_strdup.c index c891ac20..d1064ad8 100644 --- a/libft/src/str/ft_strdup.c +++ b/libft/src/str/ft_strdup.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/07 14:25:41 by jhalford #+# #+# */ -/* Updated: 2016/12/07 15:29:38 by jhalford ### ########.fr */ +/* Updated: 2017/01/10 10:56:33 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,8 @@ char *ft_strdup(const char *s1) int i; i = 0; - dup = (char*)malloc(sizeof(*dup) * (ft_strlen(s1) + 1)); + if (!s1 || !(dup = (char*)malloc(sizeof(*dup) * (ft_strlen(s1) + 1)))) + return (NULL); ft_strcpy(dup, s1); return (dup); }