fix: fixed crash on non-existent variables

index was being moved to -1 if token was only the variable, this
probably works too for variables without value
This commit is contained in:
2026-02-13 16:42:50 +01:00
parent 3ead1ad547
commit 3e31447073

View File

@@ -6,7 +6,7 @@
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/10/22 18:37:38 by sede-san #+# #+# */
/* Updated: 2026/02/13 15:07:47 by sede-san ### ########.fr */
/* Updated: 2026/02/13 15:12:48 by sede-san ### ########.fr */
/* */
/* ************************************************************************** */
@@ -152,7 +152,7 @@ static void expand_variable(
expanded = replace_value(*argument, variable_value, start - 1, end);
if (expanded == NULL)
return (minishell->exit = true, malloc_error());
*i += ft_strlen(variable_value) - 1;
*i += ft_strlen(variable_value);
free(*argument);
*argument = expanded;
}