Skip to content

Commit

Permalink
memset pid_array, fixed leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
akdovlet committed May 27, 2024
1 parent 6024fdc commit e0a72f6
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/ak_pipeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: akdovlet <akdovlet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/15 03:05:49 by akdovlet #+# #+# */
/* Updated: 2024/05/20 23:26:04 by akdovlet ### ########.fr */
/* Updated: 2024/05/27 10:43:39 by akdovlet ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down
3 changes: 2 additions & 1 deletion src/cmd_exe.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: akdovlet <akdovlet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/18 22:39:03 by akdovlet #+# #+# */
/* Updated: 2024/05/24 00:05:37 by akdovlet ### ########.fr */
/* Updated: 2024/05/27 09:35:21 by akdovlet ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -67,6 +67,7 @@ void nopath_exec(char *full_path, t_data *data)
if (!file_access(full_path, X_OK))
{
ft_dprintf(STDERR, ERR_MSG, full_path, strerror(errno));
free(full_path);
clear_all_exit(data, 126);
}
execve(full_path, data->cmd, data->env);
Expand Down
4 changes: 2 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: akdovlet <akdovlet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/20 23:07:20 by akdovlet #+# #+# */
/* Updated: 2024/05/25 21:12:10 by akdovlet ### ########.fr */
/* Updated: 2024/05/27 09:38:08 by akdovlet ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -16,7 +16,7 @@ int main(int ac, char **av, char **env)
{
t_data data;

if (ac != 5)
if (ac < 4)
{
ft_dprintf(STDERR, ERR_ARG);
return (1);
Expand Down
3 changes: 2 additions & 1 deletion src/seek_and_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: akdovlet <akdovlet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/06 23:52:25 by akdovlet #+# #+# */
/* Updated: 2024/05/20 18:06:43 by akdovlet ### ########.fr */
/* Updated: 2024/05/27 10:36:26 by akdovlet ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -20,6 +20,7 @@ void seek_and_execute(t_data *data)
data->pid_array = malloc(sizeof(pid_t) * data->cmd_count);
if (!data->pid_array)
return (clear_all_exit(data, EXIT_FAILURE));
ft_memset(data->pid_array, 0, sizeof(pid_t) * data->cmd_count);
if (data->here_doc_delimiter)
dr_here(data);
while (i < data->cmd_count - 1)
Expand Down
2 changes: 1 addition & 1 deletion src/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: akdovlet <akdovlet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/06 23:41:38 by akdovlet #+# #+# */
/* Updated: 2024/05/19 19:10:15 by akdovlet ### ########.fr */
/* Updated: 2024/05/27 10:40:05 by akdovlet ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down

0 comments on commit e0a72f6

Please sign in to comment.