boostorg / container

STL-like containers from Boost
http://www.boost.org/libs/container/
Boost Software License 1.0
100 stars 116 forks source link

Fix deallocating never-allocated storage in vector.merge() #103

Closed rolandd closed 5 years ago

rolandd commented 5 years ago

If merge() is called on an empty vector, then priv_merge_in_new_buffer() will call deallocate() with size 0 on the old (not-yet-allocated) vector storage. This violates the Allocator requirement that the pointer passed to deallocate() must have come from a call to allocate() with the same size.

Fix this by checking old_cap against 0, and also add a unit test for this bug.

igaztanaga commented 5 years ago

Many thanks for the patch.