retrieve_path() leak fixed
This commit is contained in:
@@ -6,22 +6,30 @@
|
||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/10/08 09:22:12 by lperrey #+# #+# */
|
||||
/* Updated: 2021/12/08 06:27:23 by lperrey ### ########.fr */
|
||||
/* Updated: 2021/12/22 19:28:49 by lperrey ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
char **retrieve_path(void)
|
||||
#define WARNING_PATH "Warning, $PATH not set\n"
|
||||
|
||||
int retrieve_path(char **path_stock[])
|
||||
{
|
||||
char *path;
|
||||
char **path_split;
|
||||
|
||||
path = getenv("PATH");
|
||||
if (!path)
|
||||
return (ft_retp_print(NULL, "minishell: Warning, $PATH not set\n", 2));
|
||||
{
|
||||
ft_free_2d_arr(*path_stock);
|
||||
*path_stock = NULL;
|
||||
return (shell_error(WARNING_PATH, "", "", 0));
|
||||
}
|
||||
path_split = ft_split(path, ':');
|
||||
if (!path_split)
|
||||
return (ft_retp_perror(NULL, "retrieve_path()"));
|
||||
return (path_split);
|
||||
return (ft_reti_perror(-1, "retrieve_path()"));
|
||||
ft_free_2d_arr(*path_stock);
|
||||
*path_stock = path_split;
|
||||
return (1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user