[libosmium] 02/07: Imported Upstream version 2.11.2
Bas Couwenberg
sebastic at debian.org
Wed May 3 17:00:14 UTC 2017
This is an automated email from the git hooks/post-receive script.
sebastic pushed a commit to branch master
in repository libosmium.
commit 6bbec29bd97aff81385fe6f690a42baf141d9bb5
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date: Wed May 3 18:39:30 2017 +0200
Imported Upstream version 2.11.2
---
CHANGELOG.md | 10 +++++++++-
CMakeLists.txt | 2 +-
include/osmium/memory/buffer.hpp | 15 ++++++++++++---
include/osmium/version.hpp | 4 ++--
test/t/memory/test_buffer_basics.cpp | 19 +++++++++++++++++--
5 files changed, 41 insertions(+), 9 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5aab3f3..250ec2e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
+## [2.11.2] - 2017-04-10
+
+### Fixed
+
+- Use minimum size of 64 bytes for buffers. This fixes an infinite loop
+ when buffer size is zero.
+
## [2.11.1] - 2017-03-07
@@ -531,7 +538,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
Doxygen (up to version 1.8.8). This version contains a workaround to fix
this.
-[unreleased]: https://github.com/osmcode/libosmium/compare/v2.11.1...HEAD
+[unreleased]: https://github.com/osmcode/libosmium/compare/v2.11.2...HEAD
+[2.11.2]: https://github.com/osmcode/libosmium/compare/v2.11.1...v2.11.2
[2.11.1]: https://github.com/osmcode/libosmium/compare/v2.11.0...v2.11.1
[2.11.0]: https://github.com/osmcode/libosmium/compare/v2.10.3...v2.11.0
[2.10.3]: https://github.com/osmcode/libosmium/compare/v2.10.2...v2.10.3
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 372a2a4..b823d74 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,7 +25,7 @@ project(libosmium)
set(LIBOSMIUM_VERSION_MAJOR 2)
set(LIBOSMIUM_VERSION_MINOR 11)
-set(LIBOSMIUM_VERSION_PATCH 1)
+set(LIBOSMIUM_VERSION_PATCH 2)
set(LIBOSMIUM_VERSION
"${LIBOSMIUM_VERSION_MAJOR}.${LIBOSMIUM_VERSION_MINOR}.${LIBOSMIUM_VERSION_PATCH}")
diff --git a/include/osmium/memory/buffer.hpp b/include/osmium/memory/buffer.hpp
index 370d01e..1b75b4f 100644
--- a/include/osmium/memory/buffer.hpp
+++ b/include/osmium/memory/buffer.hpp
@@ -119,6 +119,15 @@ namespace osmium {
auto_grow m_auto_grow{auto_grow::no};
std::function<void(Buffer&)> m_full;
+ static size_t calculate_capacity(size_t capacity) noexcept {
+ // The majority of all Nodes will fit into this size.
+ constexpr static const size_t min_capacity = 64;
+ if (capacity < min_capacity) {
+ return min_capacity;
+ }
+ return capacity;
+ }
+
public:
/**
@@ -198,13 +207,13 @@ namespace osmium {
* of the alignment.
*/
explicit Buffer(size_t capacity, auto_grow auto_grow = auto_grow::yes) :
- m_memory(new unsigned char[capacity]),
+ m_memory(new unsigned char[calculate_capacity(capacity)]),
m_data(m_memory.get()),
- m_capacity(capacity),
+ m_capacity(calculate_capacity(capacity)),
m_written(0),
m_committed(0),
m_auto_grow(auto_grow) {
- if (capacity % align_bytes != 0) {
+ if (m_capacity % align_bytes != 0) {
throw std::invalid_argument("buffer capacity needs to be multiple of alignment");
}
}
diff --git a/include/osmium/version.hpp b/include/osmium/version.hpp
index 1bda080..56b7e94 100644
--- a/include/osmium/version.hpp
+++ b/include/osmium/version.hpp
@@ -35,8 +35,8 @@ DEALINGS IN THE SOFTWARE.
#define LIBOSMIUM_VERSION_MAJOR 2
#define LIBOSMIUM_VERSION_MINOR 11
-#define LIBOSMIUM_VERSION_PATCH 1
+#define LIBOSMIUM_VERSION_PATCH 2
-#define LIBOSMIUM_VERSION_STRING "2.11.1"
+#define LIBOSMIUM_VERSION_STRING "2.11.2"
#endif // OSMIUM_VERSION_HPP
diff --git a/test/t/memory/test_buffer_basics.cpp b/test/t/memory/test_buffer_basics.cpp
index ffe7251..d9d174b 100644
--- a/test/t/memory/test_buffer_basics.cpp
+++ b/test/t/memory/test_buffer_basics.cpp
@@ -6,8 +6,8 @@ TEST_CASE("Buffer basics") {
osmium::memory::Buffer invalid_buffer1;
osmium::memory::Buffer invalid_buffer2;
- osmium::memory::Buffer empty_buffer1(1024);
- osmium::memory::Buffer empty_buffer2(2048);
+ osmium::memory::Buffer empty_buffer1{1024};
+ osmium::memory::Buffer empty_buffer2{2048};
REQUIRE(!invalid_buffer1);
REQUIRE(!invalid_buffer2);
@@ -32,3 +32,18 @@ TEST_CASE("Buffer basics") {
}
+TEST_CASE("Buffer with zero size") {
+ osmium::memory::Buffer buffer{0};
+ REQUIRE(buffer.capacity() == 64);
+}
+
+TEST_CASE("Buffer with less than minimum size") {
+ osmium::memory::Buffer buffer{63};
+ REQUIRE(buffer.capacity() == 64);
+}
+
+TEST_CASE("Buffer with minimum size") {
+ osmium::memory::Buffer buffer{64};
+ REQUIRE(buffer.capacity() == 64);
+}
+
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/libosmium.git
More information about the Pkg-grass-devel
mailing list