From 83d542420c87fc78ba8b3cbc0af3641e4fa91e52 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Wed, 4 Mar 2020 16:53:15 +0100 Subject: Commit --- src/ft_save_to_bmp.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/ft_save_to_bmp.c b/src/ft_save_to_bmp.c index 5d66dd2..06554ca 100644 --- a/src/ft_save_to_bmp.c +++ b/src/ft_save_to_bmp.c @@ -21,10 +21,20 @@ static char { char *str; - if (!(str = (char*)malloc((ft_strlen(ft_strrchr(ml->filename), '/') - + 1) * sizeof(char)))) - return (NULL); - ft_sprintf(str, "%s", ft_strrchr(ml->filename)); + if (ft_strrchr(ml->filename, '/')) + { + if (!(str = (char*)malloc((ft_strlen(ft_strrchr(ml->filename), '/') + + 1) * sizeof(char)))) + return (NULL); + ft_sprintf(str, "%s", ft_strrchr(ml->filename)); + } + else + { + if (!(str = (char*)malloc((ft_strlen(ml->filename) + + 1)* sizeof(char)))) + return (NULL); + ft_sprintf(str, "%s", ft_strrchr(ml->filename)); + } } static int8_t -- cgit v1.2.3