aboutsummaryrefslogtreecommitdiff
path: root/src/tokenizer.c
diff options
context:
space:
mode:
authorChristopher Uhlig2025-01-25 13:01:10 +0100
committerChristopher Uhlig2025-01-25 13:01:10 +0100
commit87b90103930d83d74baa998866b0995cb8887d51 (patch)
tree0eb876341c2794f2165b83c1d339fb3b38e9f711 /src/tokenizer.c
parent18fb7cb8ae69fc3439266a154aa6b0f947d6805d (diff)
downloadminishell-87b90103930d83d74baa998866b0995cb8887d51.tar.gz
minishell-87b90103930d83d74baa998866b0995cb8887d51.zip
fixed leaks in tokenizer and collectargs also fixed seg for < > and improved value add by $ use
Diffstat (limited to 'src/tokenizer.c')
-rw-r--r--src/tokenizer.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/tokenizer.c b/src/tokenizer.c
index 451fa50..90cb521 100644
--- a/src/tokenizer.c
+++ b/src/tokenizer.c
@@ -6,7 +6,7 @@
/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/28 20:55:50 by chuhlig #+# #+# */
-/* Updated: 2025/01/22 00:49:10 by chuhlig ### ########.fr */
+/* Updated: 2025/01/25 11:30:58 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */
@@ -60,12 +60,15 @@ void snap_string_token(char *string, int start_of_string, int i,
t_token **token_list)
{
char *line;
+ char *original;
int len;
+ line = NULL;
len = i - start_of_string + 1;
if (len > 0)
{
- line = (char *)malloc(len + 1);
+ line = (char *)malloc((sizeof(char) * len + 1));
+ original = line;
if (!line)
{
exit(EXIT_FAILURE);
@@ -79,6 +82,7 @@ void snap_string_token(char *string, int start_of_string, int i,
*token_list = new_str_token(line, *token_list, NULL);
print_token(*token_list);
}
+ free(original);
}
}