fix: segfault & leak with missing sprite image

This commit is contained in:
Khaïs COLIN 2025-08-18 12:57:29 +02:00
parent 5c7cc77419
commit c4dc4b573a
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* destroy_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tchampio <tchampio@student.42lehavre.fr> +#+ +:+ +#+ */
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/08/11 12:04:26 by tchampio #+# #+# */
/* Updated: 2025/08/12 15:39:30 by tchampio ### ########.fr */
/* Created: 2025/08/18 13:05:31 by kcolin #+# #+# */
/* Updated: 2025/08/18 13:05:31 by kcolin ### ########.fr */
/* */
/* ************************************************************************** */
@ -35,6 +35,8 @@ void destroy_sprites(t_cub3d_data *data)
int sprite;
sprite = 0;
if (data->sprite_list == NULL)
return ;
while (data->sprite_list[sprite] && sprite < MAX_SPRITES)
{
mlx_destroy_image(data->mlx, data->sprite_list[sprite]->image->img);