-
-
Notifications
You must be signed in to change notification settings - Fork 125
Closed
Description
I catch an inf loop by simple code using Buffer(size_t capacity, auto_grow auto_grow = auto_grow::yes)
ctor
// reproducing code
osmium::memory::Buffer node_buffer{0, osmium::memory::Buffer::auto_grow::yes};
osmium::builder::NodeBuilder builder{node_buffer};
Buffer(size_t capacity, auto_grow auto_grow = auto_grow::yes)
uses new unsigned char[capacity]
and set m_memory to non-null (that is "valid buffer"), however m_capacity is 0;
Because m_capacity is 0 reserve_space is infinite:
size_t new_capacity = m_capacity * 2;
while (m_written + size > new_capacity) {
new_capacity *= 2;
}
Simple fixing m_memory(capacity ? new unsigned char[capacity] : nullptr)
leads to assertion