Compare commits

...

2 Commits

Author SHA1 Message Date
Maarten L. Hekkelman
ca241bd8f2 Fix linking to std::atomic 2024-09-23 09:14:04 +02:00
Charles Beattie
e444092711 and_condition_impl::combine_equal - Remove UB container modification. (#63)
* and_condition_impl::combine_equal - Remove UB container modification.

The container is modified while iterating it.
Switched to indexed based iteration to avoid UB.

* Update condition.cpp

Sorry missed this line.
2024-09-13 17:08:18 +02:00
3 changed files with 17 additions and 8 deletions

View File

@@ -27,7 +27,7 @@ cmake_minimum_required(VERSION 3.23)
# set the project name
project(
libcifpp
VERSION 7.0.5
VERSION 7.0.6
LANGUAGES CXX)
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
@@ -369,7 +369,7 @@ target_include_directories(
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
PRIVATE "${BOOST_REGEX_INCLUDE_DIR}" "${EIGEN_INCLUDE_DIR}")
target_link_libraries(cifpp PUBLIC Threads::Threads ZLIB::ZLIB std::atomic)
target_link_libraries(cifpp PUBLIC Threads::Threads ZLIB::ZLIB $<$<TARGET_EXISTS:std::atomic>:std::atomic>)
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_link_options(cifpp PRIVATE -undefined dynamic_lookup)

View File

@@ -1,3 +1,6 @@
Version 7.0.6
- Fix linking to std::atomic
Version 7.0.5
- Fix case where category index was not updated for updated value

View File

@@ -115,27 +115,33 @@ namespace detail
auto first = subs.front();
auto &fc = first->m_sub;
for (auto c : fc)
for (size_t fc_i = 0; fc_i < fc.size();)
{
if (not found_in_range(c, subs.begin() + 1, subs.end()))
auto c = fc[fc_i];
if (not found_in_range(c, subs.begin() + 1, subs.end())) {
++fc_i;
continue;
}
if (and_result == nullptr)
and_result = new and_condition_impl();
and_result->m_sub.push_back(c);
fc.erase(remove(fc.begin(), fc.end(), c), fc.end());
fc.erase(fc.begin() + fc_i);
for (auto sub : subs)
{
auto &ssub = sub->m_sub;
for (auto sc : ssub)
for (size_t ssub_i = 0; ssub_i < ssub.size();)
{
if (not sc->equals(c))
auto sc = ssub[ssub_i];
if (not sc->equals(c)) {
++ssub_i;
continue;
}
ssub.erase(remove(ssub.begin(), ssub.end(), sc), ssub.end());
ssub.erase(ssub.begin() + ssub_i);
delete sc;
break;
}