File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -664,6 +664,7 @@ static int
664664is_utf8_encoded (const char * filename )
665665{
666666 magic_t magic_cookie = magic_open (MAGIC_MIME_ENCODING );
667+ int ret = 0 ;
667668 if (!magic_cookie )
668669 {
669670 g_warning ("%s: It is not possible initialize magic db" , __func__ );
@@ -673,20 +674,24 @@ is_utf8_encoded (const char *filename)
673674 {
674675 g_warning ("%s: It was not possible to load the default magic db" ,
675676 __func__ );
676- return -1 ;
677+ ret = -1 ;
678+ goto magic_ret ;
677679 }
678680 const char * file_encoding = magic_file (magic_cookie , filename );
679681 if (!file_encoding )
680682 {
681683 g_warning ("%s: It was not possible to identify the file encoding for %s" ,
682684 __func__ , filename );
683- return -1 ;
685+ ret = -1 ;
686+ goto magic_ret ;
684687 }
685688
686689 if (g_strstr_len (file_encoding , strlen (file_encoding ), "utf-8" ))
687- return 1 ;
690+ ret = 1 ;
688691
689- return 0 ;
692+ magic_ret :
693+ magic_close (magic_cookie );
694+ return ret ;
690695}
691696
692697/**
You can’t perform that action at this time.
0 commit comments