mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 09:58:09 +01:00
fix: check that mlx initialized succesfully before using
https://www.notion.so/Segfault-when-DISPLAY-is-invalid-233551de06f480b28d8ec14cd4b23d47?source=copy_link
This commit is contained in:
parent
8259ef238d
commit
c5f15dbf11
2 changed files with 7 additions and 2 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:14:30 by kcolin #+# #+# */
|
||||
/* Updated: 2025/07/17 15:52:57 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/07/21 11:42:12 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,6 +16,7 @@
|
|||
#include "map/map_checker.h"
|
||||
#include "draw/draw_map.h"
|
||||
#include "utils/hooks.h"
|
||||
#include "utils/frees.h"
|
||||
#include <stdbool.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/X.h>
|
||||
|
|
@ -53,6 +54,9 @@ int main(int argc, char **argv)
|
|||
return (ft_printf("Error: Wrong map file. Reason: %s\n",
|
||||
data.map->error), 1);
|
||||
data.mlx = mlx_init();
|
||||
if (data.mlx == NULL)
|
||||
return (ft_printf("Error: Failed to initalize mlx\n"),
|
||||
free_map(data.map), 1);
|
||||
data.mlx_win = mlx_new_window(data.mlx, 800, 600, "Cub3d");
|
||||
data.img_data = ft_calloc(sizeof(t_img_data), 1);
|
||||
data.img_data->img = mlx_new_image(data.mlx, 800, 600);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: kcolin <kcolin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/07/17 14:27:11 by kcolin #+# #+# */
|
||||
/* Updated: 2025/07/17 15:54:20 by kcolin ### ########.fr */
|
||||
/* Updated: 2025/07/21 11:36:53 by kcolin ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -19,5 +19,6 @@ void gnl_exhaust(int fd);
|
|||
int destroy(t_cub3d_data *data);
|
||||
void free_tab(char **tab);
|
||||
void free_tab_length(char **tab, int length);
|
||||
void free_map(t_mapdata *map);
|
||||
|
||||
#endif // FREES_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue