Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Benoit
minishell
Commits
43c6bb1a
Commit
43c6bb1a
authored
Jan 11, 2021
by
Abenoit
Browse files
few malloc checks
parent
76240782
Changes
4
Hide whitespace changes
Inline
Side-by-side
inc/minishell.h
View file @
43c6bb1a
...
...
@@ -80,7 +80,7 @@ typedef struct s_token
typedef
struct
s_command
{
t_list
*
token
s
;
char
**
arg
s
;
t_byte
pipe_flag
;
uint8_t
pad
[
7
];
}
t_command
;
...
...
src/execution/ft_export.c
View file @
43c6bb1a
...
...
@@ -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
)
{
...
...
src/execution/var_utils.c
View file @
43c6bb1a
...
...
@@ -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'
)
{
...
...
src/main.c
View file @
43c6bb1a
...
...
@@ -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
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment