fix(pwd): possible leak

This commit is contained in:
Khaïs COLIN 2025-05-05 13:04:56 +02:00
parent 4e7c9f4da9
commit dd94aba23b

View file

@ -6,7 +6,7 @@
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */ /* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/31 14:21:52 by kcolin #+# #+# */ /* Created: 2025/03/31 14:21:52 by kcolin #+# #+# */
/* Updated: 2025/04/29 15:42:51 by kcolin ### ########.fr */ /* Updated: 2025/05/05 15:28:40 by kcolin ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -27,9 +27,9 @@ static char *get_current_dir(void)
return (ft_errno(FT_EERRNO), NULL); return (ft_errno(FT_EERRNO), NULL);
while (getcwd(path, size) == NULL) while (getcwd(path, size) == NULL)
{ {
free(path);
if (errno != ERANGE) if (errno != ERANGE)
return (ft_errno(FT_EERRNO), NULL); return (ft_errno(FT_EERRNO), NULL);
free(path);
size *= 2; size *= 2;
path = ft_calloc(size, sizeof(char)); path = ft_calloc(size, sizeof(char));
if (path == NULL) if (path == NULL)