The ghostwriter::AppSettings constructor will call `setOptions()` on an Exporter nullptr if `ExporterFactory::instance()->exporterByName(exporterName);` returns nullptr. The following changes seems to fix it: diff --git a/src/appsettings.cpp b/src/appsettings.cpp index 5500108..38ca677 100644 --- a/src/appsettings.cpp +++ b/src/appsettings.cpp @@ -774,10 +774,11 @@ AppSettings::AppSettings() QString exporterName = appSettings.value(GW_LAST_USED_EXPORTER_KEY).toString(); d->currentHtmlExporter = ExporterFactory::instance()->exporterByName(exporterName); - d->currentHtmlExporter->setOptions(appSettings.value(GW_LAST_USED_EXPORTER_PARAMS_KEY).toString()); if (nullptr == d->currentHtmlExporter) { d->currentHtmlExporter = ExporterFactory::instance()->htmlExporters().first(); + } else { + d->currentHtmlExporter->setOptions(appSettings.value(GW_LAST_USED_EXPORTER_PARAMS_KEY).toString()); } }
Git commit f82070ac7916b36bb0bfd84a5c0e96cb084a6e28 by Megan Conkle. Committed on 13/10/2024 at 06:34. Pushed by wereturtle into branch 'master'. Fix segmentation fault when .conf file is missing Whenever ghostwriter.conf is missing (or the last used exporter within is empty), the app will crash with a segmentation fault due to accessing an uninitialed pointer to the current HTML exporter in appsettings.cpp. This commit ensures that the pointer is initialized to null before being checked for whether obtaining an exporter was successful. M +6 -0 CHANGELOG.md M +12 -12 src/preview/htmlpreview.cpp M +12 -6 src/settings/appsettings.cpp https://invent.kde.org/office/ghostwriter/-/commit/f82070ac7916b36bb0bfd84a5c0e96cb084a6e28