substr alloue memoire en cas de nul

This commit is contained in:
Hugo LAMY
2019-11-28 16:35:13 +01:00
parent 365e8abb42
commit 07a2d393ef
3 changed files with 49 additions and 20 deletions

View File

@@ -6,7 +6,7 @@
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/25 14:01:58 by hulamy #+# #+# */
/* Updated: 2019/11/27 19:54:09 by hulamy ### ########.fr */
/* Updated: 2019/11/28 16:32:34 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -41,7 +41,7 @@ char *ft_substr(char const *s, unsigned int start, size_t len)
if (!s)
return (NULL);
if (ft_strlen(s) < start)
return ("");
return (ft_strdup(""));
if (!(str = (char *)malloc(sizeof(char) * (len + 1))))
return (NULL);
i = 0;