From: meng an <[email protected]> In function vdi_object_map, the pointer 'inode' is allocated via xmalloc, but its memory is not released when returns.
Signed-off-by: Meng An <[email protected]> --- dog/vdi.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dog/vdi.c b/dog/vdi.c index 9fc1677..30739ff 100644 --- a/dog/vdi.c +++ b/dog/vdi.c @@ -864,15 +864,14 @@ static int vdi_object_map(int argc, char **argv) uint64_t idx = vdi_cmd_data.index; struct sd_inode *inode = xmalloc(sizeof(*inode)); uint32_t vid; - int ret; + int ret = EXIT_SUCCESS; ret = read_vdi_obj(vdiname, vdi_cmd_data.snapshot_id, vdi_cmd_data.snapshot_tag, NULL, inode, SD_INODE_SIZE); if (ret != EXIT_SUCCESS) { sd_err("FATAL: %s not found", vdiname); - free(inode); - return ret; + goto out; } printf("Index VID\n"); @@ -888,7 +887,10 @@ static int vdi_object_map(int argc, char **argv) printf("%08"PRIu64" %8"PRIx32"\n", idx, vid); } } - return EXIT_SUCCESS; + +out: + free(inode); + return ret; } static void print_expected_location(uint64_t oid, int copies) -- 1.7.1 -- sheepdog mailing list [email protected] http://lists.wpkg.org/mailman/listinfo/sheepdog
