From 71c069ef097a16553bfed1868954c80581c83724 Mon Sep 17 00:00:00 2001 From: Jaakko Heinonen Date: Tue, 2 Apr 2002 21:12:44 +0000 Subject: [PATCH 1/1] abook_fopen() bugfix --- abook.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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) { -- 2.39.2