aboutsummaryrefslogtreecommitdiff
path: root/libbible.cc
diff options
context:
space:
mode:
authorYour Name <you@example.com>2020-11-07 07:56:08 -0500
committerYour Name <you@example.com>2020-11-07 07:56:08 -0500
commit67207e20f3dc8b9e92e45560776b5b304f964cc1 (patch)
tree1c766f0869194b2ae0adf4b57d7470140a3a5d6c /libbible.cc
parent44f16b6cd5b9cd9641c0c5df1c671c9e610ad7ac (diff)
downloadlibbible-67207e20f3dc8b9e92e45560776b5b304f964cc1.tar.gz
libbible-67207e20f3dc8b9e92e45560776b5b304f964cc1.tar.bz2
libbible-67207e20f3dc8b9e92e45560776b5b304f964cc1.zip
Fixed segfaults for invalid module names
Diffstat (limited to 'libbible.cc')
-rw-r--r--libbible.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/libbible.cc b/libbible.cc
index 7b08174..29e8873 100644
--- a/libbible.cc
+++ b/libbible.cc
@@ -42,6 +42,10 @@ map<string, vector<string>> libbible::getModules() {
vector<libbible::passage> libbible::getPassages(string modName, string book) {
vector<libbible::passage> passages;
SWModule *target = library.getModule(modName.c_str());
+ if(target == nullptr) {
+ // Module doesn't exist
+ return passages;
+ }
target->setKey((book + " " + "1").c_str());
VerseKey *key = (VerseKey *) target->getKey();
int maxChapter = key->getChapterMax();
@@ -124,13 +128,17 @@ void inferMissing(libbible::passage *pass, SWModule *target) {
}
vector<libbible::text> libbible::getText(libbible::passage pass) {
+ vector<libbible::text> texts;
SWModule *target = library.getModule(pass.modName.c_str());
+ if(target == nullptr) {
+ // Module doesn't exist
+ return texts;
+ }
inferMissing(&pass, target);
target->setKey((pass.book
+ " " + to_string(pass.chapterStart)
+ ":" + to_string(pass.verseStart)).c_str());
VerseKey *key = (VerseKey *) target->getKey();
- vector<libbible::text> texts;
bool endOfParagraph = false;