mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
fix(expand_star): memory leak
You have to call closedir(). I also removed the errno checking to make some space, I don't think it is needed when looking at the errors returned by these functions.
This commit is contained in:
parent
32e3976774
commit
f06f6e26e2
1 changed files with 4 additions and 7 deletions
|
|
@ -3,10 +3,10 @@
|
|||
/* ::: :::::::: */
|
||||
/* wildcard_exp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/20 15:01:38 by jguelen #+# #+# */
|
||||
/* Updated: 2025/03/21 18:42:04 by jguelen ### ########.fr */
|
||||
/* Updated: 2025/04/03 19:58:36 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -104,20 +104,17 @@ static t_wordlist *expand_star_core(t_worddesc *file_pattern)
|
|||
if (current_dir == NULL)
|
||||
return (NULL);
|
||||
file_wordlist = NULL;
|
||||
errno = 0;
|
||||
new = readdir(current_dir);
|
||||
while (new)
|
||||
{
|
||||
if (fits_pattern(new->d_name, file_pattern))
|
||||
{
|
||||
if (add_file_to_list(&file_wordlist, new->d_name) == NULL)
|
||||
return (NULL);
|
||||
return (closedir(current_dir), NULL);
|
||||
}
|
||||
errno = 0;
|
||||
new = readdir(current_dir);
|
||||
}
|
||||
if (errno)
|
||||
return (wordlist_destroy(file_wordlist), NULL);
|
||||
closedir(current_dir);
|
||||
if (!file_wordlist)
|
||||
file_wordlist = wordlist_independant_create(file_pattern);
|
||||
return (wordlist_quicksort_full(file_wordlist));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue