fix open external zim

Check if the parameter `pathToSave` is empty before use it otherwise the
book path is empty too, which causes crash on opening external zim files
This commit is contained in:
luddens 2020-04-13 16:07:27 +02:00
parent 8fc42558d3
commit 0586ef6d41
1 changed files with 1 additions and 1 deletions

View File

@ -175,7 +175,7 @@ std::string Manager::addBookFromPathAndGetId(const std::string& pathToOpen,
kiwix::Book book; kiwix::Book book;
if (this->readBookFromPath(pathToOpen, &book)) { if (this->readBookFromPath(pathToOpen, &book)) {
if (pathToSave != pathToOpen) { if (!pathToSave.empty() && pathToSave != pathToOpen) {
book.setPath(isRelativePath(pathToSave) book.setPath(isRelativePath(pathToSave)
? computeAbsolutePath( ? computeAbsolutePath(
removeLastPathElement(writableLibraryPath), removeLastPathElement(writableLibraryPath),