[Botan-devel] [PATCH] Bug in Pooling_Allocator::allocate()

Jack Lloyd lloyd at randombit.net
Fri Nov 25 22:27:29 EST 2005


Thanks! This looks good to me and will be applied as part of 1.4.10. I
currently have that release targetted for mid-December but may push that up a
bit.

Regards,
  Jack

On Sat, Nov 26, 2005 at 04:18:09PM +1300, Matthew Gregan wrote:
> Hello,
> 
> Please find attached a small patch for a bug I ran into recently.
> 
> Botan's Pooling_Allocator assumes that Buffers stored in free_list are
> sorted, and uses std::inplace_merge() in deallocate() to ensure that each
> freed Buffer is positioned in free_list in order.  The same check was not
> being performed when a Buffer was added to free_list in allocate().
> 
> Cheers,
> -mjg
> -- 
> Matthew Gregan                     |/
>                                   /|                kinetik at orcon.net.nz

> # 
> # 
> # patch "botan/mem_pool.cpp"
> #  from [3b09bd3c3d6fdf3aa854529239e9d4e4d8ac18f5]
> #    to [54ee4313712d9f47ad38cdfc5ad00d890d607de5]
> # 
> ============================================================
> --- botan/mem_pool.cpp	3b09bd3c3d6fdf3aa854529239e9d4e4d8ac18f5
> +++ botan/mem_pool.cpp	54ee4313712d9f47ad38cdfc5ad00d890d607de5
> @@ -159,6 +159,9 @@
>     if(!block.buf)
>        throw Memory_Exhaustion();
>     free_list.push_back(block);
> +   if(free_list.size() >= 2)
> +      std::inplace_merge(free_list.begin(), free_list.end() - 1,
> +                         free_list.end());
>  
>     new_buf = find_free_block(n);
>     if(new_buf)

> _______________________________________________
> botan-devel mailing list
> botan-devel at randombit.net
> http://www.randombit.net/mailman/listinfo/botan-devel




More information about the botan-devel mailing list