From: Victor Wagner Date: Wed, 27 Apr 2016 04:48:49 +0000 (+0300) Subject: Fixed incorrect handling of NULLs in check_charset X-Git-Tag: REL_0_95~4 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=4c1c2b85914997dfaab4718b2723bdb5ba2ef779;p=oss%2Fcatdoc.git Fixed incorrect handling of NULLs in check_charset --- diff --git a/src/charsets.c b/src/charsets.c index eda5cb4..5c58c76 100644 --- a/src/charsets.c +++ b/src/charsets.c @@ -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; diff --git a/src/fileutil.c b/src/fileutil.c index 86139ec..ce0bdb7 100644 --- a/src/fileutil.c +++ b/src/fileutil.c @@ -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; }