From: Jaakko Heinonen Date: Tue, 2 Apr 2002 21:12:44 +0000 (+0000) Subject: abook_fopen() bugfix X-Git-Tag: upstream/0.6.1~2^2~276 X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=71c069ef097a16553bfed1868954c80581c83724;p=pkg%2Fabook.git abook_fopen() bugfix --- diff --git a/abook.c b/abook.c index 101dd69..7bc654d 100644 --- a/abook.c +++ b/abook.c @@ -605,17 +605,18 @@ FILE * abook_fopen (const char *path, const char *mode) { struct stat s; + bool stat_ok; - if((stat(path, &s)) == -1) - return NULL; + stat_ok = (stat(path, &s) != -1); if(strchr(mode, 'r')) - return S_ISREG(s.st_mode) ? fopen(path, mode) : NULL; + return (stat_ok && S_ISREG(s.st_mode)) ? + fopen(path, mode) : NULL; else - return S_ISDIR(s.st_mode) ? NULL : fopen(path, mode); + return (stat_ok && S_ISDIR(s.st_mode)) ? + NULL : fopen(path, mode); } - static void convert(char *srcformat, char *srcfile, char *dstformat, char *dstfile) {