File 0008-Fix-segfault-when-bad-empty-.ini-file-is-detected.patch of Package wangemu
From a051fb81f9207d03773aa0abb14eb4131f79f040 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= <kkaempf@gmail.com>
Date: Tue, 14 Oct 2025 09:36:20 +0200
Subject: [PATCH 08/11] Fix segfault when bad/empty .ini file is detected
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Klaus Kämpf <kkaempf@gmail.com>
---
src/system2200.cpp | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/system2200.cpp b/src/system2200.cpp
index ebd9961..fe336cf 100644
--- a/src/system2200.cpp
+++ b/src/system2200.cpp
@@ -1,4 +1,4 @@
-// this encapsulates the system under emulation.
+#// this encapsulates the system under emulation.
#include "CardInfo.h"
#include "Cpu2200.h"
@@ -255,10 +255,16 @@ system2200::initialize()
SysCfgState ini_cfg;
ini_cfg.loadIni();
if (!ini_cfg.configOk(false)) {
- UI_warn(".ini file wasn't usable -- using a default configuration");
+ /* UI_warn runs the scheduler, which calls system2200::onIdle() and then cpu->status()
+ * however, 'cpu' is still NULL and causes a SIGSEGV.
+ * Call setConfig() early here, ensuring cpu != NULL */
ini_cfg.setDefaults();
+ setConfig(ini_cfg);
+ UI_warn(".ini file wasn't usable -- using a default configuration");
+ }
+ else {
+ setConfig(ini_cfg);
}
- setConfig(ini_cfg);
#if 0
// intentional error, to see if the leak checker finds it
--
2.51.0