|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r78310 - in sandbox/pool: boost/pool libs/pool/test
From: svart.riddare_at_[hidden]
Date: 2012-05-02 16:19:01
Author: edupuis
Date: 2012-05-02 16:19:00 EDT (Wed, 02 May 2012)
New Revision: 78310
URL: http://svn.boost.org/trac/boost/changeset/78310
Log:
Prevent division by zero when requesting null sized buffers. Fixes #5902.
Added:
sandbox/pool/libs/pool/test/test_bug_5902.cpp (contents, props changed)
Text files modified:
sandbox/pool/boost/pool/pool.hpp | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
Modified: sandbox/pool/boost/pool/pool.hpp
==============================================================================
--- sandbox/pool/boost/pool/pool.hpp (original)
+++ sandbox/pool/boost/pool/pool.hpp 2012-05-02 16:19:00 EDT (Wed, 02 May 2012)
@@ -711,8 +711,8 @@
BOOST_USING_STD_MIN();
if(!max_size)
next_size <<= 1;
- else if( next_size*partition_size/requested_size < max_size)
- next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size*requested_size/ partition_size);
+ else if(next_size < max_size * requested_size / partition_size)
+ next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size * requested_size / partition_size);
// initialize it,
store().add_block(node.begin(), node.element_size(), partition_size);
@@ -751,8 +751,8 @@
BOOST_USING_STD_MIN();
if(!max_size)
next_size <<= 1;
- else if( next_size*partition_size/requested_size < max_size)
- next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size*requested_size/ partition_size);
+ else if(next_size < max_size * requested_size / partition_size)
+ next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size * requested_size / partition_size);
// initialize it,
// (we can use "add_block" here because we know that
@@ -843,8 +843,8 @@
BOOST_USING_STD_MIN();
if(!max_size)
next_size <<= 1;
- else if( next_size*partition_size/requested_size < max_size)
- next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size*requested_size/ partition_size);
+ else if(next_size < max_size * requested_size / partition_size)
+ next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size * requested_size / partition_size);
// insert it into the list,
// handle border case.
Added: sandbox/pool/libs/pool/test/test_bug_5902.cpp
==============================================================================
--- (empty file)
+++ sandbox/pool/libs/pool/test/test_bug_5902.cpp 2012-05-02 16:19:00 EDT (Wed, 02 May 2012)
@@ -0,0 +1,21 @@
+/* Copyright (C) 2012 Étienne Dupuis
+*
+* Use, modification and distribution is subject to the
+* Boost Software License, Version 1.0. (See accompanying
+* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+// Test of bug #5902 (https://svn.boost.org/trac/boost/ticket/5902)
+
+#include <boost/pool/pool.hpp>
+
+int main()
+{
+ boost::pool<> p(0, 1, 1);
+
+ p.malloc();
+ p.ordered_malloc();
+ p.ordered_malloc(48);
+
+ return 0;
+}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk