Segfault was caused by trying to destroy image that was not initialized
/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/02 08:44:53 by ljiriste #+# #+# */
-/* Updated: 2024/04/04 10:38:20 by ljiriste ### ########.fr */
+/* Updated: 2024/04/04 10:47:06 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
int init_state(t_state *state)
{
state->graph.mlx_ses.mlx = mlx_init();
+ state->graph.mlx_ses.mlx_win = NULL;
state->pos.x = 0;
state->pos.y = 0;
return (ft_vec_init(&state->found, sizeof(t_position)) != success
/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/04 10:27:01 by ljiriste #+# #+# */
-/* Updated: 2024/04/04 10:37:03 by ljiriste ### ########.fr */
+/* Updated: 2024/04/04 10:48:19 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
if (!s->mlx_win)
{
- mlx_destroy_image(s->mlx, to_print.img);
+ if (to_print.img)
+ mlx_destroy_image(s->mlx, to_print.img);
return (0);
}
if (!to_print.img)