mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 09:58:09 +01:00
fix: potential leak with gnl due to non-exhaustion
This commit is contained in:
parent
085a51ca6d
commit
d7efc43f12
3 changed files with 23 additions and 4 deletions
|
|
@ -3,16 +3,17 @@
|
|||
/* ::: :::::::: */
|
||||
/* frees.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
|
||||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/06/25 17:46:01 by tchampio #+# #+# */
|
||||
/* Updated: 2025/07/15 10:26:48 by tchampio ### ########.fr */
|
||||
/* Created: 2025/07/17 13:59:27 by kcolin #+# #+# */
|
||||
/* Updated: 2025/07/17 14:00:01 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../includes/cub3d_consts.h"
|
||||
#include "../../includes/structs.h"
|
||||
#include "../../mlx/mlx.h"
|
||||
#include "../../includes/libft.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void free_tab(char **tab)
|
||||
|
|
@ -56,3 +57,19 @@ int destroy(t_cub3d_data *data)
|
|||
exit(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
Calls get_next_line in a loop until NULL is returned, freeing all data returned.
|
||||
Ensures that all memory allocated by get_next_line is properly freed.
|
||||
*/
|
||||
void gnl_exhaust(int fd)
|
||||
{
|
||||
char *line;
|
||||
|
||||
line = get_next_line(fd);
|
||||
while (line != NULL)
|
||||
{
|
||||
free(line);
|
||||
line = get_next_line(fd);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue