mirror of
https://github.com/Icinga/icinga2.git
synced 2026-02-03 20:40:17 -05:00
vec[1] is equivalent to vec[vec.size()] at that point and thus not a valid
element of the vector, making the use of operator[] undefined behavior here.
With some compiler flags (like those used in package builds on RHEL and
similar), the compiler (rightfully) aborts the program on this out of bounds
access:
68/178 Test #68: base-base_string/vector_move ............................................***Failed 0.01 sec
/usr/include/c++/14/bits/stl_vector.h:1130: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = icinga::String; _Alloc = std::allocator<icinga::String>; reference = icinga::String&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.
Running 1 test case...
unknown location(0): fatal error: in "base_string/vector_move": signal: SIGABRT (application abort requested)
/builds/packages/icinga2/packaging/fedora/41/BUILD/icinga2-2.14.5+467.g206d7cda1-build/icinga2-2.14.5+467.g206d7cda1/test/base-string.cpp(120): last checkpoint
*** 1 failure is detected in the test module "icinga2"
This commit fixes this by taking the indirection through .data() and using
plain pointer arithmetic instead.
|
||
|---|---|---|
| .. | ||
| config | ||
| livestatus | ||
| base-array.cpp | ||
| base-base64.cpp | ||
| base-convert.cpp | ||
| base-dictionary.cpp | ||
| base-fifo.cpp | ||
| base-io-engine.cpp | ||
| base-json.cpp | ||
| base-match.cpp | ||
| base-netstring.cpp | ||
| base-object-packer.cpp | ||
| base-object.cpp | ||
| base-serialize.cpp | ||
| base-shellescape.cpp | ||
| base-stacktrace.cpp | ||
| base-stream.cpp | ||
| base-string.cpp | ||
| base-timer.cpp | ||
| base-tlsutility.cpp | ||
| base-type.cpp | ||
| base-utility.cpp | ||
| base-value.cpp | ||
| CMakeLists.txt | ||
| config-apply.cpp | ||
| config-ops.cpp | ||
| icinga-checkable-fixture.cpp | ||
| icinga-checkable-flapping.cpp | ||
| icinga-checkresult.cpp | ||
| icinga-dependencies.cpp | ||
| icinga-legacytimeperiod.cpp | ||
| icinga-macros.cpp | ||
| icinga-notification.cpp | ||
| icinga-perfdata.cpp | ||
| icingaapplication-fixture.cpp | ||
| icingaapplication-fixture.hpp | ||
| livestatus-fixture.cpp | ||
| livestatus.cpp | ||
| methods-pluginnotificationtask.cpp | ||
| remote-configpackageutility.cpp | ||
| remote-url.cpp | ||
| test-runner.cpp | ||