Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Commit

Permalink
fix memory errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mcombeau committed Oct 6, 2022
1 parent bb90105 commit a234e1f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
12 changes: 12 additions & 0 deletions .ignore_readline_leaks.supp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
ignore_readline_leaks
Memcheck:Leak
...
fun:readline
}
{
ignore_rl_history_leaks
Memcheck:Leak
...
fun:add_history
}
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
NAME = minishell

# Compiler and compilation flags
CC = clang -g
CFLAGS = -Werror -Wextra -Wall -g
CC = clang
CFLAGS = -Werror -Wextra -Wall -gdwarf-4 -g

# Build files and directories
SRC_PATH = ./sources/
Expand Down Expand Up @@ -88,7 +88,7 @@ $(OBJ_PATH)%.o: $(SRC_PATH)%.c

# Project file rule
$(NAME): $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $@ $(INC) $(LIBFT) -lreadline
$(CC) $(CFLAGS) $(OBJS) -o $@ $(INC) $(LIBFT) -l readline

# Libft rule
$(LIBFT):
Expand Down
4 changes: 2 additions & 2 deletions sources/execution/execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: mcombeau <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/17 17:09:49 by mcombeau #+# #+# */
/* Updated: 2022/09/26 19:54:05 by mcombeau ### ########.fr */
/* Updated: 2022/10/06 12:52:27 by mcombeau ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -87,7 +87,7 @@ static bool prep_for_exec(t_data *data)
{
if (!cmd->args)
{
cmd->args = malloc(sizeof * cmd->args);
cmd->args = malloc(sizeof * cmd->args * 2);
cmd->args[0] = ft_strdup(cmd->command);
cmd->args[1] = NULL;
}
Expand Down
9 changes: 5 additions & 4 deletions sources/signals/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: mcombeau <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/17 18:06:43 by mcombeau #+# #+# */
/* Updated: 2022/09/27 14:42:18 by mcombeau ### ########.fr */
/* Updated: 2022/10/06 12:50:46 by mcombeau ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -34,7 +34,7 @@ void set_interactive_signal_trap(void)
{
struct sigaction act;

ft_memset(&act, 0, sizeof(sigaction));
ft_memset(&act, 0, sizeof(act));
act.sa_handler = &signal_reset_prompt;
sigaction(SIGINT, &act, NULL);
}
Expand All @@ -59,7 +59,7 @@ void set_noninteractive_signal_trap(void)
{
struct sigaction act;

ft_memset(&act, 0, sizeof(sigaction));
ft_memset(&act, 0, sizeof(act));
act.sa_handler = &signal_print_newline;
sigaction(SIGINT, &act, NULL);
sigaction(SIGQUIT, &act, NULL);
Expand All @@ -73,7 +73,8 @@ void ignore_sigquit(void)
{
struct sigaction act;

ft_bzero(&act, sizeof(act));
ft_memset(&act, 0, sizeof(act));
// ft_bzero(&act, sizeof(act));
act.sa_handler = SIG_IGN;
sigaction(SIGQUIT, &act, NULL);
}

0 comments on commit a234e1f

Please sign in to comment.