ft_lstlast: fix segfault when lst=NULL
This commit is contained in:
parent
d9097ecd53
commit
4709b5929a
1 changed files with 3 additions and 1 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/10/21 12:03:16 by kcolin #+# #+# */
|
/* Created: 2024/10/21 12:03:16 by kcolin #+# #+# */
|
||||||
/* Updated: 2024/10/21 12:04:50 by kcolin ### ########.fr */
|
/* Updated: 2024/10/21 13:16:06 by kcolin ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -16,6 +16,8 @@ t_list *ft_lstlast(t_list *lst)
|
||||||
{
|
{
|
||||||
t_list *current;
|
t_list *current;
|
||||||
|
|
||||||
|
if (lst == NULL)
|
||||||
|
return (NULL);
|
||||||
current = lst;
|
current = lst;
|
||||||
while (current->next != NULL)
|
while (current->next != NULL)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue