]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osdmap: fix null deref in dump
authorSage Weil <sage@inktank.com>
Tue, 9 Oct 2012 03:50:12 +0000 (20:50 -0700)
committerSage Weil <sage@inktank.com>
Tue, 9 Oct 2012 03:50:12 +0000 (20:50 -0700)
CID 731938 (#1 of 1): Dereference after null check (FORWARD_NULL)
At (15): Passing null pointer "f" to function "ceph::Formatter::dump_int(char const *, int64_t)", which dereferences it. (The dereference happens because this is a virtual function call.)

Signed-off-by: Sage Weil <sage@inktank.com>
src/osd/OSDMap.cc

index 62411bfdcab891d5461f9ee790d293e2bbe19deb..2c38c807a2c0bc43ba1c596f25c35e06201b098b 100644 (file)
@@ -1526,7 +1526,8 @@ void OSDMap::print_tree(ostream *out, Formatter *f) const
       for (int k=s-1; k>=0; k--) {
        int item = crush->get_bucket_item(cur, k);
        q.push_front(qi(item, depth+1, (float)crush->get_bucket_item_weight(cur, k) / (float)0x10000));
-       f->dump_int("child", item);
+       if (f)
+         f->dump_int("child", item);
       }
       if (f)
        f->close_section();