Fix missing terminator null in assignment
authorLukas Jiriste <ljiriste@student.42prague.com>
Mon, 22 Jul 2024 20:55:40 +0000 (22:55 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Mon, 22 Jul 2024 20:55:40 +0000 (22:55 +0200)
Instead there of terminating null there was a space left by the add_word
function. That also caused wrong concatenation of chained var expansions

src/execution.c

index fa928b7c789591b98b7d153aa0ab46cd66c90b58..8169c6bce9538928c312947566bb3736db28369c 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <ljiriste@student.42prague.com>   +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   Created: 2024/07/21 08:57:54 by ljiriste          #+#    #+#             */
-/*   Updated: 2024/07/22 22:29:04 by ljiriste         ###   ########.fr       */
+/*   Updated: 2024/07/22 22:54:45 by ljiriste         ###   ########.fr       */
 /*                                                                            */
 /* ************************************************************************** */
 
@@ -65,6 +65,7 @@ int   add_assignment(t_vec *assignments, const char *assignment, const t_execution
                return (1);
        if (add_word(&advanced_copy, assignment, env))
                return (1);
+       *(char *)ft_vec_access(&advanced_copy, advanced_copy.size - 1) = '\0';
        copy = advanced_copy.vec;
        unquote_field(copy);
        clear_old(assignments, copy);