Browse Source

[fix] ft_strlen: avoid segfault when str is NULL.

Moul 4 years ago
parent
commit
2b065147fb
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/ft_strlen.c

+ 2 - 2
src/ft_strlen.c

@@ -6,7 +6,7 @@
 /*   By: mazimi <mazimi@student.42.fr>              +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2014/11/03 15:02:39 by mazimi            #+#    #+#             */
-/*   Updated: 2014/12/21 13:11:04 by mazimi           ###   ########.fr       */
+/*   Updated: 2016/06/13 13:54:40 by mazimi           ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -17,7 +17,7 @@ size_t	ft_strlen(char const *str)
 	int i;
 
 	i = 0;
-	while (str[i])
+	while (str && str[i])
 		i++;
 	return (i);
 }