]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
buffer::ptr self assignment bug + patch 44/head
authorLoic Dachary <loic@dachary.org>
Sun, 10 Feb 2013 13:23:36 +0000 (14:23 +0100)
committerLoic Dachary <loic@dachary.org>
Sun, 10 Feb 2013 14:32:35 +0000 (15:32 +0100)
commit749218f155969fd87a6194b26acd00a9332d522d
tree0c3e6f2106b00c6fa3eb7d24d118b8c6fc250f47
parentabc80ffc5b1aab3915c049701ab85c57fe93d550
buffer::ptr self assignment bug + patch

After

buffer::ptr a(1);
a = a;

a call to a.get_raw() will return a null pointer and there will be
no pointer referencing the original buffer::raw object although its
reference count is 1.

buffer::ptr& buffer::ptr::operator= (const ptr& p) is modified to use
a local buffer::raw pointer to fix the memory leak. a = a
is a noop instead of loosing the original raw buffer.

A set of unit tests is added src/test/bufferlist.cc to demonstrate
that the proposed change works as expected. It is checked with
valgrind that reports no memory leak. The same test can be run against
the original code to show that it leaks.

http://tracker.ceph.com/issues/4070 refs #4070

Signed-off-by: Loic Dachary <loic@dachary.org>
src/common/buffer.cc
src/test/bufferlist.cc