From f7bd6d516a52bd395849e40bbfaa9cf47f33a905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= Date: Thu, 16 May 2019 09:05:09 +0200 Subject: [PATCH] Fix #9267: Only check if a file is a directory before opening it (#9269) --- src/openrct2/core/FileStream.hpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/openrct2/core/FileStream.hpp b/src/openrct2/core/FileStream.hpp index c2bc81c918..0839b9994f 100644 --- a/src/openrct2/core/FileStream.hpp +++ b/src/openrct2/core/FileStream.hpp @@ -76,9 +76,16 @@ public: free(pathW); free(modeW); #else - struct stat fileStat; - // Only allow regular files to be opened as its possible to open directories. - if (stat(path, &fileStat) == 0 && S_ISREG(fileStat.st_mode)) + if (fileMode == FILE_MODE_OPEN) + { + struct stat fileStat; + // Only allow regular files to be opened as its possible to open directories. + if (stat(path, &fileStat) == 0 && S_ISREG(fileStat.st_mode)) + { + _file = fopen(path, mode); + } + } + else { _file = fopen(path, mode); }