diff --git a/src/search.cpp b/src/search.cpp index 99f69e6..75ebfc8 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -129,8 +129,9 @@ void cleanup_text(string &text) { static const boost::regex re_header_start{"<[hH][1-6]"}; static const boost::regex re_header_end{"]+pagebreak[^>]+" + "(title|aria-label)" + "=\"([[:alnum:]]+)\""}; size_t pos{}; while ((pos = text.find('<', pos)) != string::npos) @@ -149,8 +150,8 @@ void cleanup_text(string &text) { auto endpos{text.find('>')}; boost::match_results match; - if (boost::regex_search(text.substr(pos, endpos).data(), match, - re_pagebreak)) + if (boost::regex_search(text.substr(pos, endpos - pos).data(), + match, re_pagebreak)) { // FIXME: -fsanitize=address is complaining about this. ↓ 🤷 // Could not reproduce it.