Skip to content

Commit e10c5ca

Browse files
committed
[~] Fix new crash with unsetenv
1 parent 875d6a6 commit e10c5ca

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/builtins/unsetenv.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ static void search_and_delete(char **args, char **env, char **new_env)
4444
skip_variables(args, env, &index);
4545
new_env[index_new] = env[index];
4646
index_new++;
47+
if (env[index] == NULL)
48+
break;
4749
}
4850
new_env[index_new] = NULL;
4951
}

src/environnement.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void replace_env_var(char **env, char *name, char *value)
6767
*/
6868
void check_path(mysh_t *mysh)
6969
{
70-
char *path = get_env_var(mysh->env, "PATH");
70+
char *path = my_malloc_strdup(get_env_var(mysh->env, "PATH"));
7171

7272
if (path == NULL)
7373
add_variable(mysh, "path", "/usr/bin /bin");

0 commit comments

Comments
 (0)