diff --git a/cmake/debug_flags.cmake b/cmake/debug_flags.cmake index df17971..52abc89 100644 --- a/cmake/debug_flags.cmake +++ b/cmake/debug_flags.cmake @@ -25,7 +25,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" "-Wformat=2" "-ftrapv" "-fsanitize=undefined" - # "-fsanitize=address" + "-fsanitize=address" "-Og" "-fno-omit-frame-pointer") if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") @@ -47,8 +47,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" list(APPEND tmp_LDFLAGS "-fsanitize=undefined" - # "-fsanitize=address" - ) + "-fsanitize=address") # add_link_options was introduced in version 3.13. if(${CMAKE_VERSION} VERSION_LESS 3.13) set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${tmp_LDFLAGS}") diff --git a/src/search.cpp b/src/search.cpp index 75ebfc8..ddc227c 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -149,12 +149,16 @@ void cleanup_text(string &text) else if (text.substr(pos, 6) == "')}; - boost::match_results match; - if (boost::regex_search(text.substr(pos, endpos - pos).data(), - match, re_pagebreak)) + + boost::match_results match; + using it_size_t = string::const_iterator::difference_type; + string::const_iterator begin{text.begin() + + static_cast(pos)}; + string::const_iterator end{text.end() + + static_cast(endpos)}; + + if (boost::regex_search(begin, end, match, re_pagebreak)) { - // FIXME: -fsanitize=address is complaining about this. ↓ 🤷 - // Could not reproduce it. replacement = format("", match[2].str()); } } @@ -240,9 +244,9 @@ match_context context(const boost::match_results &match, words -= 1; } - const std::string before_reversed(rbegin_before, pos_before); + const string before_reversed(rbegin_before, pos_before); string before(before_reversed.rbegin(), before_reversed.rend()); - std::string after(begin_after, pos_after); + string after(begin_after, pos_after); while (helpers::is_whitespace(*before.begin())) { before.erase(0, 1);