From c5d94d9d8b313b5b68692bc54a70a469f5b998ca Mon Sep 17 00:00:00 2001
From: Jonas Kulla <Nyocurio@gmail.com>
Date: Sat, 18 May 2019 16:48:17 +0200
Subject: [PATCH] FileSystem: Check PHYSFS_registerArchiver() for success

---
 src/filesystem.cpp | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/filesystem.cpp b/src/filesystem.cpp
index f448ac5..70d5065 100644
--- a/src/filesystem.cpp
+++ b/src/filesystem.cpp
@@ -325,13 +325,18 @@ FileSystem::FileSystem(const char *argv0,
 	if (PHYSFS_init(argv0) == 0)
 		throwPhysfsError("Error initializing PhysFS");
 
+	/* One error (=return 0) turns the whole product to 0 */
+	int er = 1;
+	er *= PHYSFS_registerArchiver(&RGSS1_Archiver);
+	er *= PHYSFS_registerArchiver(&RGSS2_Archiver);
+	er *= PHYSFS_registerArchiver(&RGSS3_Archiver);
+
+	if (er == 0)
+		throwPhysfsError("Error registering PhysFS RGSS archiver");
+
 	p = new FileSystemPrivate;
 	p->havePathCache = false;
 
-	PHYSFS_registerArchiver(&RGSS1_Archiver);
-	PHYSFS_registerArchiver(&RGSS2_Archiver);
-	PHYSFS_registerArchiver(&RGSS3_Archiver);
-
 	if (allowSymlinks)
 		PHYSFS_permitSymbolicLinks(1);
 }