Skip to content

Commit

Permalink
Merge pull request #726 from kiwix/622-corrupted-zim-leads-to-crash
Browse files Browse the repository at this point in the history
622 corrupted zim leads to crash
  • Loading branch information
kelson42 authored Apr 20, 2024
2 parents 5eb6868 + 06f7e32 commit 6675ffe
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions SwiftUI/Model/SearchOperation/SearchOperation.mm
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ - (void)performSearch {
// get a list of archives that are included in search
typedef std::unordered_map<std::string, zim::Archive> archives_map;
auto *allArchives = static_cast<archives_map *>([[ZimFileService sharedInstance] getArchives]);

std::vector<zim::Archive> indexSearchArchives = std::vector<zim::Archive>();
std::vector<zim::Archive> titleSearchArchives = std::vector<zim::Archive>();
for (NSUUID *zimFileID in self.zimFileIDs) {
Expand All @@ -63,11 +63,13 @@ - (void)performSearch {
indexSearchArchives.push_back(archive);
}
titleSearchArchives.push_back(archive);
} catch (std::out_of_range) { }
} catch (std::exception) { }
}

// perform index and title search
[self addIndexSearchResults:indexSearchArchives];
try {
[self addIndexSearchResults:indexSearchArchives];
} catch (std::exception) { }
if (titleSearchArchives.size() > 0) {
int count = std::max((35 - (int)[self.results count]) / (int)titleSearchArchives.size(), 5);
[self addTitleSearchResults:titleSearchArchives count:(int)count];
Expand Down

0 comments on commit 6675ffe

Please sign in to comment.