Fixes #151 ("Buffer overflow in monotonic_buffer_resource::do_allocate").

This commit is contained in:
Ion Gaztañaga committed 2020-07-12 11:07:50 +02:00
1 parent 4f37a023b0
commit 90de9533ec
2 files changed
+4

No files matched your search

+3
View File
@@ -141,6 +141,9 @@ void* monotonic_buffer_resource::do_allocate(std::size_t bytes, std::size_t alig
//See if there is room in current buffer
std::size_t aligner = 0u;
if(this->remaining_storage(alignment, aligner) < bytes){
//The new buffer will be aligned to the strictest alignment so reset
//the aligner, which was needed for the old buffer.
aligner = 0u;
//Update next_buffer_size to at least bytes
this->increase_next_buffer_at_least_to(bytes);
//Now allocate and update internal data