From cf02f7aab507daa7e362c1781e03a0f528c64659 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 19 Feb 2018 09:47:15 -0500 Subject: [PATCH] [libcalamares] Avoid nullptr crashes - The Python testmodule script can end up calling in to System methods (via System::instance()). This is unusual, and the System instance has not been created at that point. Now, create an instance and warn about it. --- src/libcalamares/utils/CalamaresUtilsSystem.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libcalamares/utils/CalamaresUtilsSystem.cpp b/src/libcalamares/utils/CalamaresUtilsSystem.cpp index ff5aac874..9729386d4 100644 --- a/src/libcalamares/utils/CalamaresUtilsSystem.cpp +++ b/src/libcalamares/utils/CalamaresUtilsSystem.cpp @@ -58,8 +58,15 @@ System::~System() {} -System*System::instance() +System* +System::instance() { + if ( !s_instance ) + { + cError() << "No Calamares system-object has been created."; + cError() << " .. using a bogus instance instead."; + return new System( true, nullptr ); + } return s_instance; }