From 4a70e4469720c351cb5abb5463979beeef3dd38d Mon Sep 17 00:00:00 2001 From: Theo Champion Date: Thu, 14 Aug 2025 21:27:53 +0200 Subject: [PATCH] fix: Added a check for the sprites, to avoid segfaults and/or invalid writes --- src/utils/inits.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/utils/inits.c b/src/utils/inits.c index d904b41..39045e4 100644 --- a/src/utils/inits.c +++ b/src/utils/inits.c @@ -6,7 +6,7 @@ /* By: kcolin +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/07/31 13:43:05 by kcolin #+# #+# */ -/* Updated: 2025/08/12 16:13:50 by tchampio ### ########.fr */ +/* Updated: 2025/08/14 21:26:14 by tchampio ### ########.fr */ /* */ /* ************************************************************************** */ @@ -69,8 +69,11 @@ void place_base_sprites(t_cub3d_data *data, char **map) { if (map[y][x] == 'M' || map[y][x] == 'Q' || map[y][x] == 'J' || map[y][x] == 'D') - data->sprite_list[c++] = place_right_sprite(data, - map[y][x], x, y); + { + if (c < MAX_SPRITES) + data->sprite_list[c++] = place_right_sprite(data, + map[y][x], x, y); + } x++; } y++;