From eec73973a450932ee2888c10a4034f42e497a2c7 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 23 Feb 2022 12:58:16 -0500 Subject: Fixed segfault when no modules are installed or set as default --- src/bible.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/bible.cc b/src/bible.cc index a09c0c0..4da2326 100644 --- a/src/bible.cc +++ b/src/bible.cc @@ -31,7 +31,19 @@ void usage() { } string getDefaultModule() { - return libbible::settingsRead("module"); + map> mods = libbible::getModules(); + string mod = libbible::settingsRead("module"); + if(mods.count(mod) > 0) { + return mod; + } + if(!mods.empty()) { + // Just get one + for(auto pair : mods) { + return pair.first.c_str(); + } + } + printf("ERROR: No mods installed!\n"); + exit(1); } void listModules() { -- cgit v1.2.3