From 7c9b1b391f67f47dfa9b11dd9e205a7679009397 Mon Sep 17 00:00:00 2001 From: James Turner <zakalawe@mac.com> Date: Fri, 15 Jun 2018 11:10:51 +0100 Subject: [PATCH] Guard against SGPath::document()s returning null Underlying bug is fixed in SimGear, but let's also guard against a failure here, by falling back to FG_HOME on Windows. For discussion see: https://sourceforge.net/p/flightgear/codetickets/2019/ --- src/Main/options.cxx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 358cb274c..13c3b0ade 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -2456,11 +2456,15 @@ SGPath defaultDownloadDir() { #if defined(SG_WINDOWS) SGPath p(SGPath::documents()); - p.append("FlightGear"); -#else - SGPath p(globals->get_fg_home()); + if (p.isNull()) { + SG_LOG(SG_IO, SG_ALERT, "Failed to locate user's Documents directory, will default to FG_HOME"); + // fall through to standard get_fg_home codepath + } else { + return p / "FlightGear"; + } #endif - return p; + + return globals->get_fg_home(); } OptionResult Options::processOptions()