From 1f947c5dfe27a9f7ef5734d4ab16a01317e50fe1 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Fri, 28 Aug 2020 17:53:11 +0200 Subject: Fixing double free redir, export and preprocess on empty value --- src/builtin/export.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/builtin/export.c') diff --git a/src/builtin/export.c b/src/builtin/export.c index 6fbb88f..e19756d 100644 --- a/src/builtin/export.c +++ b/src/builtin/export.c @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 17:11:34 by charles #+# #+# */ -/* Updated: 2020/07/19 18:46:48 by charles ### ########.fr */ +/* Updated: 2020/08/28 17:49:47 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -40,7 +40,6 @@ int builtin_export(char **argv, t_env env) int status; size_t i; char *equal_ptr; - bool skip; if (argv[1] == NULL) { @@ -51,20 +50,18 @@ int builtin_export(char **argv, t_env env) i = 0; while (argv[++i] != NULL) { - skip = (equal_ptr = ft_strchr(argv[i], '=')) == NULL; - if (!skip) + equal_ptr = ft_strchr(argv[i], '='); + if (equal_ptr != NULL) *equal_ptr = '\0'; if (!utils_valid_identifier(argv[i])) { - if (!skip) + if (equal_ptr != NULL) *equal_ptr = '='; errorf("export: `%s': not a valid identifier\n", argv[i]); status = 1; continue; } - if (skip) - continue; - if (env_export(env, argv[i], equal_ptr + 1) == NULL) + if (env_export(env, argv[i], equal_ptr == NULL ? "" : equal_ptr + 1) == NULL) return (127); // malloc error } return (status); -- cgit