Skip to content

Commit b01c2d9

Browse files
committed
fixed a segmentation fault if the map is empty
1 parent 5554a53 commit b01c2d9

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

bonus/ft_map_parse_bonus.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ int ft_map_parse(t_game *game)
4141
if (fd < 0)
4242
return (0);
4343
line = get_next_line(fd);
44+
if (!line)
45+
return (0);
4446
while (line)
4547
{
4648
lines = ft_strjoin(lines, line);

mandatory/ft_map_parse.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ int ft_map_parse(t_game *game)
4141
if (fd < 0)
4242
return (0);
4343
line = get_next_line(fd);
44+
if (!line)
45+
return (0);
4446
while (line)
4547
{
4648
lines = ft_strjoin(lines, line);

0 commit comments

Comments
 (0)