Fixed a subtle problem in counted_base::release (report and test case by Per Kristensen)

[SVN r16211]
This commit is contained in:
Peter Dimov
2002-11-12 13:14:50 +00:00
parent 57c0ad44f3
commit ff7410cad2
2 changed files with 57 additions and 2 deletions
+11 -2
View File
@@ -120,19 +120,28 @@ public:
void release() // nothrow
{
long new_use_count;
long new_weak_count;
long new_weak_count = 0;
{
#ifdef BOOST_HAS_THREADS
mutex_type::scoped_lock lock(mtx_);
#endif
new_use_count = --use_count_;
new_weak_count = --weak_count_;
if(new_use_count != 0)
{
new_weak_count = --weak_count_;
}
}
if(new_use_count == 0)
{
dispose();
#ifdef BOOST_HAS_THREADS
mutex_type::scoped_lock lock(mtx_);
#endif
new_weak_count = --weak_count_;
}
if(new_weak_count == 0)