summaryrefslogtreecommitdiffstats
path: root/src/s_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/s_init.c')
-rw-r--r--src/s_init.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/s_init.c b/src/s_init.c
index a572c32..a13f9f1 100644
--- a/src/s_init.c
+++ b/src/s_init.c
@@ -11,13 +11,13 @@
/* ************************************************************************** */
#include <libft.h>
-#include <stdlib.h>
-#include <unistd.h>
#ifdef __linux__
# include <linux/limits.h>
#else
# include <limits.h>
#endif
+#include <stdlib.h>
+#include <unistd.h>
#include "b_export_next.h"
#include "d_define.h"
@@ -108,8 +108,12 @@ t_msh *s_init_msh(int argc, char *const argv[], char *const envp[])
if ((msh = (t_msh*)malloc(sizeof(t_msh))) == NULL)
return (NULL);
msh->envp = NULL;
+ (void)envp;
if ((msh->envp = s_dupenv(envp)) == NULL)
+ {
+ ft_memdel((void*)&msh);
return (NULL);
+ }
msh->argc = argc - 1;
msh->argv = (char**)argv;
msh->ret = 0;
@@ -118,11 +122,13 @@ t_msh *s_init_msh(int argc, char *const argv[], char *const envp[])
s_set_cwd(cwd, msh);
if ((msh->cwd = ft_strdup(cwd)) == NULL)
{
+ ft_delwords(msh->envp);
ft_memdel((void*)&msh);
return (NULL);
}
msh->env_fork_tmp[0][0] = '\0';
- s_inc_shlvl(msh);
+ if (s_inc_shlvl(msh) == 1)
+ return (NULL);
s_init_sqb_ref_one(msh);
s_init_sqb_ref_two(msh);
s_init_sqb_ref_thr(msh);