]> www.wagner.pp.ru Git - oss/catdoc.git/commitdiff
Fixed incorrect handling of NULLs in check_charset
authorVictor Wagner <vitus@wagner.pp.ru>
Wed, 27 Apr 2016 04:48:49 +0000 (07:48 +0300)
committerVictor Wagner <vitus@wagner.pp.ru>
Wed, 27 Apr 2016 04:48:49 +0000 (07:48 +0300)
src/charsets.c
src/fileutil.c

index eda5cb4caa24e413357b779c229cd8e5150766bb..5c58c7623c5ebd88eaa6b687a7371b9607284b86 100644 (file)
@@ -69,7 +69,7 @@ CHARSET make_reverse_map(short int *charset) {
 /************************************************************************/
 /* Reads charset file (as got from ftp.unicode.org) and returns array of*/
 /* 256 short ints (malloced) mapping from charset t unicode             */
-/************************************************************************/int * read_charset(const char *filename) {
+/************************************************************************/
 uint16_t * read_charset(const char *filename) {
        char *path;
        FILE *f;
index 86139ecdb833e332679d5ec03078b7198319713c..ce0bdb7b50d3405b0c4b87b4715c297f8284f4ce 100644 (file)
@@ -99,19 +99,18 @@ char *find_file(char *name, const char *path)
 /************************************************************************/
 int check_charset(char **filename,const char *charset) {
        char *tmppath;
+       if (charset == NULL ) {
+               return 0;
+       }
        if (!strncmp(charset,"utf-8",6)) {
                *filename=strdup("utf-8");
                return 1;
        }   
        tmppath=find_file(stradd(charset,CHARSET_EXT),charset_path);
-       /* Some compilers evalate both arguments of && before
-          applying, so let's not use && as in the shell */
-       if (tmppath) {
-           if (*tmppath) {
+       if (tmppath && *tmppath) {
                        *filename=strdup(charset);
                        free(tmppath);
                        return 1;
-               }
        }
        return 0;
 }