From a0162bebe67964cd020ee6b06290db10bcf653dc Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Wed, 13 Apr 2011 13:14:00 +0200 Subject: [PATCH] Block selection of a directory when file is needed When we are not browsing merely to obtain a name to put in a text edit, but really must return an open file pointer, selection of a directory (ending in '/') can no longer be OK'ed in the file browser. (XBoard tends to segfault when offered garbage for game or position file...) --- filebrowser/selfile.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/filebrowser/selfile.c b/filebrowser/selfile.c index d3f02f3..f59e159 100644 --- a/filebrowser/selfile.c +++ b/filebrowser/selfile.c @@ -855,8 +855,8 @@ XsraSelFile(toplevel, prompt, ok, cancel, failed, SFprepareToReturn(); return stderr; } - if (fp = SFopenFile(*name_return, mode, - prompt, failed)) { + if ((*name_return)[strlen(*name_return)-1] != '/' && // [HGM] refuse directories + (fp = SFopenFile(*name_return, mode, prompt, failed))) { SFprepareToReturn(); return fp; } -- 1.7.0.4