From 89a454db7fde22ffd64b98466db977417a915e2b Mon Sep 17 00:00:00 2001 From: nicolas-arnaud Date: Sun, 20 Nov 2022 17:48:46 +0100 Subject: [PATCH] fix segfault --- .gitignore | 6 ++---- src/parsing/parsing.c | 1 + src/parsing/utils.c | 2 ++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 4f3ff34..81100dd 100644 --- a/.gitignore +++ b/.gitignore @@ -5,11 +5,9 @@ !Makefile !README.md -!*.h !includes/ - -!*.a -!lib/ +!cub3d.h +!mlx_keycode.h !*.cub !maps/ diff --git a/src/parsing/parsing.c b/src/parsing/parsing.c index 7579064..0c6c55f 100644 --- a/src/parsing/parsing.c +++ b/src/parsing/parsing.c @@ -24,6 +24,7 @@ int cleanup_datas(t_env *env) free(env->tex[3].file); if (env->tex[4].file) free(env->tex[4].file); + free(env); return (1); } diff --git a/src/parsing/utils.c b/src/parsing/utils.c index 47e1ff0..c5593c5 100644 --- a/src/parsing/utils.c +++ b/src/parsing/utils.c @@ -39,6 +39,8 @@ int rgb_to_int(char **rgb) while (c < 3 && rgb && colors) { colors = next_split(&i, colors, &rgb); + if (!colors || !colors[i]) + continue ; color = ft_atoi(colors[i++]); if (color >= 0 && color < 256) ret |= color << (8 * (2 - c++));