From 358090fb9656e816b5394f9bd3ccbae26a129170 Mon Sep 17 00:00:00 2001 From: Xuan Sang LE Date: Fri, 2 Mar 2018 21:28:04 +0100 Subject: [PATCH] fix --- libs/utils.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/utils.c b/libs/utils.c index ca266ee..c0a367b 100644 --- a/libs/utils.c +++ b/libs/utils.c @@ -144,7 +144,7 @@ char* ext(const char* file) if(file == NULL) return NULL; char* str_cpy = strdup(file); char* str_org = str_cpy; - if(strstr(str_cpy,".")<= 0) return ""; + if(strstr(str_cpy,".")<= 0) return strdup(""); if(*file == '.') trim(str_cpy,'.'); @@ -184,7 +184,8 @@ char* mime(const char* file) { char * ex = ext(file); mime_t m = mime_from_ext(ex); - free(ex); + if(ex) + free(ex); return m.type; } @@ -192,7 +193,8 @@ int is_bin(const char* file) { char * ex = ext(file); mime_t m = mime_from_ext(ex); - free(ex); + if(ex) + free(ex); return m.bin; }