]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: Monitor: fix potential null-pointer dereference
authorJoao Eduardo Luis <joao.luis@inktank.com>
Wed, 17 Oct 2012 14:23:11 +0000 (15:23 +0100)
committerJoao Eduardo Luis <joao.luis@inktank.com>
Wed, 17 Oct 2012 14:23:11 +0000 (15:23 +0100)
CID 717443: Dereference after null check (FORWARD_NULL)
At (14): Passing null pointer "detailbl" to function
"ceph::buffer::list::append(std::string const &)", which dereferences it.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
src/mon/Monitor.cc

index 73280b0e8780a1c264d3a167f348ccc8c1df4d38..910cf81b96093377533371a963204be059ae9f78 100644 (file)
@@ -1324,8 +1324,10 @@ void Monitor::get_health(string& status, bufferlist *detailbl, Formatter *f)
   while (!detail.empty()) {
     if (f)
       f->dump_string("item", detail.front().second);
-    detailbl->append(detail.front().second);
-    detailbl->append('\n');
+    if (detailbl != NULL) {
+      detailbl->append(detail.front().second);
+      detailbl->append('\n');
+    }
     detail.pop_front();
   }
   if (f)