From 3e14bbb05d2f7c77734646e25618c7f1b2200ec4 Mon Sep 17 00:00:00 2001 From: Arthur-gtr Date: Thu, 17 Apr 2025 11:01:07 +0200 Subject: [PATCH] [FIX] error with the malloc due to the missing parentheses --- src/init_history.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/init_history.c b/src/init_history.c index 614db37..99b2d5b 100644 --- a/src/init_history.c +++ b/src/init_history.c @@ -15,7 +15,7 @@ static char *get_arg(char *line, int x, int end_cmd) { - char *tmp = malloc(sizeof(char) * (x - end_cmd) + 1); + char *tmp = malloc(sizeof(char) * ((x - end_cmd) + 1)); if (tmp != NULL) { tmp = strncpy(tmp, &line[end_cmd], x - end_cmd); @@ -31,7 +31,7 @@ his_command_t set_cmd(char *line, his_command_t cmd_struct) while (line[x] != '\0' && !isblank(line[x])) x++; - cmd_struct.command = malloc(sizeof(char) * x + 1); + cmd_struct.command = malloc((sizeof(char) * x + 1)); if (cmd_struct.command != NULL) { cmd_struct.command = strncpy(cmd_struct.command, line, x); cmd_struct.command[x] = '\0';