]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: Fix operator= null ptr references
authorDavid Zafman <dzafman@redhat.com>
Thu, 13 Nov 2014 01:43:24 +0000 (17:43 -0800)
committerSage Weil <sage@redhat.com>
Fri, 14 Nov 2014 00:36:55 +0000 (16:36 -0800)
Fixes: #10082
dzafman-2014-11-13_10:42:58-rgw-wip-10082-testing-basic-multi

Reviewed-by: Sage Weil <sage@redhat.com>
Signed-off-by: David Zafman <dzafman@redhat.com>
src/librados/librados.cc

index 66663b0c43da81ddef1ab4031ad4294e43784613..1e795be5e1b51a1a875fab288b28902885948808 100644 (file)
@@ -647,6 +647,7 @@ librados::NObjectIterator::~NObjectIterator()
 librados::NObjectIterator::NObjectIterator(const NObjectIterator &rhs)
 {
   if (rhs.impl == NULL) {
+    delete impl;
     impl = NULL;
     return;
   }
@@ -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);
@@ -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;
   }
@@ -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);