Commit f9bb6481 authored by zhujiashun's avatar zhujiashun

Fix a memory leak in doubly_buffered_data.h

parent 8c398d88
......@@ -27,6 +27,7 @@
#include "butil/type_traits.h"
#include "butil/errno.h"
#include "butil/atomicops.h"
#include "butil/unique_ptr.h"
namespace butil {
......@@ -238,17 +239,17 @@ private:
template <typename T, typename TLS>
typename DoublyBufferedData<T, TLS>::Wrapper*
DoublyBufferedData<T, TLS>::AddWrapper() {
Wrapper* w = new (std::nothrow) Wrapper(this);
std::unique_ptr<Wrapper> w(new (std::nothrow) Wrapper(this));
if (NULL == w) {
return NULL;
}
try {
BAIDU_SCOPED_LOCK(_wrappers_mutex);
_wrappers.push_back(w);
_wrappers.push_back(w.get());
} catch (std::exception& e) {
return NULL;
}
return w;
return w.release();
}
// Called when thread quits.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment