Skip to content

Commit

Permalink
librados: Fix operator= null ptr references
Browse files Browse the repository at this point in the history
Fixes: ceph#10082

dzafman-2014-11-13_10:42:58-rgw-wip-10082-testing-basic-multi

Reviewed-by: Sage Weil <[email protected]>
Signed-off-by: David Zafman <[email protected]>
  • Loading branch information
dzafman authored and liewegas committed Nov 14, 2014
1 parent 20f99ca commit cba4ed4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/librados/librados.cc
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ librados::NObjectIterator::~NObjectIterator()
librados::NObjectIterator::NObjectIterator(const NObjectIterator &rhs)
{
if (rhs.impl == NULL) {
delete impl;
impl = NULL;
return;
}
Expand All @@ -656,6 +657,11 @@ librados::NObjectIterator::NObjectIterator(const NObjectIterator &rhs)

librados::NObjectIterator& librados::NObjectIterator::operator=(const librados::NObjectIterator &rhs)
{
if (rhs.impl == NULL) {
delete impl;
impl = NULL;
return *this;
}
if (impl == NULL)
impl = new NObjectIteratorImpl();
*impl = *(rhs.impl);
Expand Down Expand Up @@ -4507,6 +4513,7 @@ librados::ListObject::ListObject(librados::ListObjectImpl *i): impl(i)
librados::ListObject::ListObject(const ListObject& rhs)
{
if (rhs.impl == NULL) {
delete impl;
impl = NULL;
return;
}
Expand All @@ -4516,6 +4523,11 @@ librados::ListObject::ListObject(const ListObject& rhs)

librados::ListObject& librados::ListObject::operator=(const ListObject& rhs)
{
if (rhs.impl == NULL) {
delete impl;
impl = NULL;
return *this;
}
if (impl == NULL)
impl = new ListObjectImpl();
*impl = *(rhs.impl);
Expand Down

0 comments on commit cba4ed4

Please sign in to comment.