From 4b2ad9e65ff98bdd29b1e69c761483a18a20e6a5 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 9 Dec 2014 10:14:06 -0500 Subject: [PATCH] port image_data fixes from image_data_any branch --- include/mapnik/image_data.hpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/include/mapnik/image_data.hpp b/include/mapnik/image_data.hpp index 23f53394b..3ce19c6a3 100644 --- a/include/mapnik/image_data.hpp +++ b/include/mapnik/image_data.hpp @@ -41,10 +41,17 @@ struct buffer data_(static_cast(size_ != 0 ? ::operator new(size_) : nullptr)) {} - buffer(buffer && rhs) noexcept = default; + buffer(buffer && rhs) noexcept + : size_(std::move(rhs.size_)), + data_(std::move(rhs.data_)) + { + rhs.size_ = 0; + rhs.data_ = nullptr; + } + buffer(buffer const& rhs) : size_(rhs.size_), - data_(rhs.data_) + data_(static_cast(size_ != 0 ? ::operator new(size_) : nullptr)) { if (data_) std::copy(rhs.data_, rhs.data_ + rhs.size_, data_); } @@ -63,6 +70,7 @@ struct buffer }; + } template @@ -173,7 +181,9 @@ public: } inline void setRow(std::size_t row, std::size_t x0, std::size_t x1, pixel_type const* buf) { - std::copy(buf, buf + (x1 - x0), pData_ + row * width_); + assert(row < height_); + assert ((x1 - x0) <= width_ ); + std::copy(buf, buf + (x1 - x0), pData_ + row * width_ + x0); } private: std::size_t width_;