]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: use delete[] properly
authorSage Weil <sage@inktank.com>
Thu, 15 Nov 2012 00:59:06 +0000 (16:59 -0800)
committerSage Weil <sage@inktank.com>
Thu, 15 Nov 2012 01:05:39 +0000 (17:05 -0800)
==4986== Mismatched free() / delete / delete []
==4986==    at 0x4C2658C: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4986==    by 0x4ED8EA9: librbd::ImageCtx::~ImageCtx() (ImageCtx.cc:100)
==4986==    by 0x4EF3827: librbd::close_image(librbd::ImageCtx*) (internal.cc:1869)
==4986==    by 0x4EE8FB8: librbd::clone(librados::IoCtx&, char const*, char const*, librados::IoCtx&, char const*, unsigned long, int*, unsigned long, int) (internal.cc:900)
==4986==    by 0x4EC363C: rbd_clone2 (librbd.cc:553)
==4986==    by 0x404C85: do_clone (fsx.c:836)
==4986==    by 0x405639: test (fsx.c:1048)
==4986==    by 0x406369: main (fsx.c:1523)
==4986==  Address 0xd498b30 is 0 bytes inside a block of size 37 alloc'd
==4986==    at 0x4C26CF7: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4986==    by 0x4ED9B4D: librbd::ImageCtx::init_layout() (ImageCtx.cc:164)
==4986==    by 0x4ED9845: librbd::ImageCtx::init() (ImageCtx.cc:142)
==4986==    by 0x4EF3449: librbd::open_image(librbd::ImageCtx*, bool) (internal.cc:1828)
==4986==    by 0x4EE89E0: librbd::clone(librados::IoCtx&, char const*, char const*, librados::IoCtx&, char const*, unsigned long, int*, unsigned long, int) (internal.cc:871)
==4986==    by 0x4EC363C: rbd_clone2 (librbd.cc:553)
==4986==    by 0x404C85: do_clone (fsx.c:836)
==4986==    by 0x405639: test (fsx.c:1048)
==4986==    by 0x406369: main (fsx.c:1523)

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

index 69ad195f8515aee6d5dccb27afa977b5ca41b523..b29a2caaab7ffd6278970e698d919f4563d636bf 100644 (file)
@@ -97,7 +97,7 @@ namespace librbd {
       delete object_set;
       object_set = NULL;
     }
-    delete format_string;
+    delete[] format_string;
   }
 
   int ImageCtx::init() {
@@ -159,7 +159,7 @@ namespace librbd {
     layout.fl_object_size = 1ull << order;
     layout.fl_pg_pool = data_ctx.get_id();  // FIXME: pool id overflow?
 
-    delete format_string;
+    delete[] format_string;
     size_t len = object_prefix.length() + 16;
     format_string = new char[len];
     if (old_format) {