Skip to content

Commit

Permalink
1) free(path) in ft_pwd.c
Browse files Browse the repository at this point in the history
2) add pipe.c to Makefile
  • Loading branch information
ftimothy committed Nov 22, 2021
1 parent 8c306d7 commit cf68492
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ SRC = srcs/env.c \
srcs/ft_pwd.c \
srcs/ft_cd.c \
srcs/ft_cd_nullify_preceding_pathname.c \
srcs/pipe.c \

OBJ = $(SRC:%.c=%.o)

Expand Down
9 changes: 6 additions & 3 deletions srcs/ft_pwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ int ft_pwd(char **args, int *fd)
i = 0;
while (fd[i])
{
if (write(fd[i], path, ft_strlen(path)) == -1)
return (-1);
if (write(fd[i], "\n", 1) == -1)
if (write(fd[i], path, ft_strlen(path)) == -1
|| write(fd[i], "\n", sizeof(char)) == -1)
{
free(path);
return (-1);
}
i++;
}
free(path);
return (1);
}

0 comments on commit cf68492

Please sign in to comment.