aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ft_save_to_bmp.c18
1 files 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