Skip to content

Commit

Permalink
Updated to Boost Version 1.63.0
Browse files Browse the repository at this point in the history
Fixed bug where `operator[]` was used to read the address of the one-past-the-end element of a `boost::container::vector`.
  • Loading branch information
Mankarse committed Mar 30, 2017
1 parent 18dda85 commit cfba000
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ext/ExternalDependencies.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
==== HourglassII External Dependencies Configuration ====
HourglassII depends on the following libraries:

Boost version 1.59.0 -- http://www.boost.org/users/history/version_1_59_0.html
Boost version 1.63.0 -- http://www.boost.org/users/history/version_1_63_0.html
SFML version 2.4.2 -- http://www.sfml-dev.org/download.php
Threading Building Blocks version 2017 Update 5 -- http://threadingbuildingblocks.org

Expand Down
5 changes: 1 addition & 4 deletions src/LayeredCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
#include <boost/range/algorithm/stable_sort.hpp>
#include <algorithm>

#include <boost/bind/bind.hpp>
#include <boost/ref.hpp>

namespace hg {

namespace lc_internal {
Expand Down Expand Up @@ -129,7 +126,7 @@ Flusher LayeredCanvas::getFlusher() {
void Flusher::partialFlush(int upperLimit) {
boost::container::vector<lc_internal::DrawCall>::iterator lowerBound(upperBound);
upperBound = std::upper_bound(lowerBound, boost::end(canvas->drawCalls), DrawCall{upperLimit, clone_ptr<Drawer>(nullptr)});
std::for_each(lowerBound, upperBound, boost::bind(&DrawCall::drawTo, _1, boost::ref(*canvas->canvas)));
std::for_each(lowerBound, upperBound, [this](lc_internal::DrawCall const &drawCall) { drawCall.drawTo(*canvas->canvas); });
}
Flusher::Flusher(LayeredCanvas *canvas) : canvas(canvas) {
boost::stable_sort(canvas->drawCalls);
Expand Down
11 changes: 10 additions & 1 deletion src/multi_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,18 @@ class multi_vector {
static std::size_t const current_axis = N_dims - 1;
//public:
U &operator[](std::size_t i) const {
//These two assertions could be placed in a constructor.
//They do not depend on i.
assert(this_->data.size() >= this_->size[current_axis]);
assert(std::less_equal<>()(array_start, this_->data.data() + this_->data.size()));
assert(std::less_equal<>()(array_start, this_->data.data() + this_->data.size() - this_->size[current_axis]));

assert(current_axis < this_->size.size());
assert(i < this_->size[current_axis]);
assert(array_start+i >= this_->data.data() && array_start+i < &this_->data[this_->data.size()]);
//TODO: This assert invokes undefined behaviour if violated! (Due to inter-array comparisons/creation of invalid pointers)
//Not sure how to avoid this. I believe the earlier assertions in combination are equivalent to this assertion; so maybe this
//assertion can just be removed.
assert(array_start+i >= this_->data.data() && array_start+i < this_->data.data() + this_->data.size());
return array_start[i];
}
};
Expand Down

0 comments on commit cfba000

Please sign in to comment.