From 4c1c2b85914997dfaab4718b2723bdb5ba2ef779 Mon Sep 17 00:00:00 2001 From: Victor Wagner Date: Wed, 27 Apr 2016 07:48:49 +0300 Subject: [PATCH] Fixed incorrect handling of NULLs in check_charset --- src/charsets.c | 2 +- src/fileutil.c | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) 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; } -- 2.39.2