diff options
author | Your Name <you@example.com> | 2022-02-23 12:58:16 -0500 |
---|---|---|
committer | Your Name <you@example.com> | 2022-02-23 12:58:16 -0500 |
commit | eec73973a450932ee2888c10a4034f42e497a2c7 (patch) | |
tree | 823100f143310449f528c5d4efae4cd614a496d7 /src/bible.cc | |
parent | 0054b0d1dcf1a2d2950cc297b9c595a793827f7a (diff) | |
download | libbible-eec73973a450932ee2888c10a4034f42e497a2c7.tar.gz libbible-eec73973a450932ee2888c10a4034f42e497a2c7.tar.bz2 libbible-eec73973a450932ee2888c10a4034f42e497a2c7.zip |
Fixed segfault when no modules are installed or set as default
Diffstat (limited to 'src/bible.cc')
-rw-r--r-- | src/bible.cc | 14 |
1 files changed, 13 insertions, 1 deletions
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<string, vector<string>> 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() { |