Commit 43c6bb1a authored by Abenoit's avatar Abenoit
Browse files

few malloc checks

parent 76240782
......@@ -80,7 +80,7 @@ typedef struct s_token
typedef struct s_command
{
t_list *tokens;
char **args;
t_byte pipe_flag;
uint8_t pad[7];
} t_command;
......
......@@ -37,7 +37,7 @@ int print_export(char **env, char **exported)
variables = sort_variables(env, exported);
if (variables == NULL)
return (FAILURE);
return (MALLOC_ERR);
i = 0;
while (variables[i] != NULL)
{
......
......@@ -7,11 +7,15 @@ int env_replace_var(char *var_name, char *value, t_xe *xe)
int j;
new = malloc(sizeof(char*) * 3);
if (new == NULL)
return (MALLOC_ERR);
new[0] = ft_strdup("export");
if (new[0] == NULL)
return (MALLOC_ERR);
new[1] = malloc(sizeof(char) * (ft_strlen(var_name) + ft_strlen(value) + 2));
new[2] = NULL;
if (new == NULL)
if (new[1] == NULL)
return (MALLOC_ERR);
new[2] = NULL;
i = 0;
while (var_name[i] != '\0')
{
......
......@@ -7,6 +7,7 @@
#include <sys/types.h> // waitpid
#include <sys/wait.h> // waitpid
static int get_input(char **line)
{
int ret;
......@@ -189,6 +190,8 @@ int main(int argc, char **argv, char **env_source)
(void)argv;
ret = SUCCESS;
xe = (t_xe *)malloc(sizeof(t_xe));
if (xe == NULL)
return (ft_exit(MALLOC_ERR, xe));
ft_bzero(xe, sizeof(t_xe));
if (xe == NULL)
ret = MALLOC_ERR;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment