From 6077015fdc7196015b19a404b0c8d624f70c3f6b Mon Sep 17 00:00:00 2001 From: Misa Date: Mon, 15 Feb 2021 18:03:52 -0800 Subject: [PATCH] Guard PHYSFS_deinit() with PHYSFS_isInit() A quick glance at PhysFS source code will show that PhysFS will bail if PHYSFS_deinit() is called if it's not initialized. "Bail" here just means setting an error code and returning early, so it's not that bad. Still, it's the principle of the thing, and I just want to ensure that FILESYSTEM_deinit() can be safely called no matter if the filesystem hasn't initialized yet; having an error set by PhysFS kind of taints the whole safety thing, even if it does nothing wrong, no? (although, speaking of which, we should be handling all errors by PhysFS, but that's for later...) --- desktop_version/src/FileSystemUtils.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index ecbca62f..074460ed 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -134,7 +134,10 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath) void FILESYSTEM_deinit() { - PHYSFS_deinit(); + if (PHYSFS_isInit()) + { + PHYSFS_deinit(); + } } char *FILESYSTEM_getUserSaveDirectory()