From: Theodore Ts'o Date: Mon, 15 Jun 2009 07:50:07 +0000 (-0400) Subject: e2fsck: fix miscellaneous memory leaks X-Git-Tag: v1.41.7~19 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=23f75f6efaac6b756e0f3e4e1d33b6798347f66a;p=tools%2Fe2fsprogs.git e2fsck: fix miscellaneous memory leaks Fix various miscellaneous memory leaks which were discovered using valgrind. Signed-off-by: "Theodore Ts'o" --- diff --git a/e2fsck/dirinfo.c b/e2fsck/dirinfo.c index fb2887b..901235c 100644 --- a/e2fsck/dirinfo.c +++ b/e2fsck/dirinfo.c @@ -293,6 +293,9 @@ void e2fsck_free_dir_info(e2fsck_t ctx) unlink(ctx->dir_info->tdb_fn); free(ctx->dir_info->tdb_fn); } + if (ctx->dir_info->array) + ext2fs_free_mem(&ctx->dir_info->array); + ctx->dir_info->array = 0; ctx->dir_info->size = 0; ctx->dir_info->count = 0; ext2fs_free_mem(&ctx->dir_info); diff --git a/e2fsck/dx_dirinfo.c b/e2fsck/dx_dirinfo.c index eba6add..5c48d32 100644 --- a/e2fsck/dx_dirinfo.c +++ b/e2fsck/dx_dirinfo.c @@ -115,7 +115,7 @@ void e2fsck_free_dx_dir_info(e2fsck_t ctx) if (ctx->dx_dir_info) { dir = ctx->dx_dir_info; - for (i=0; i < ctx->dx_dir_info_count; i++) { + for (i=0; i < ctx->dx_dir_info_count; i++,dir++) { if (dir->dx_block) { ext2fs_free_mem(&dir->dx_block); dir->dx_block = 0; diff --git a/e2fsck/pass1b.c b/e2fsck/pass1b.c index d08ece4..99f0a3c 100644 --- a/e2fsck/pass1b.c +++ b/e2fsck/pass1b.c @@ -180,6 +180,7 @@ static void inode_dnode_free(dnode_t *node, next = p->next; free(p); } + free(di); free(node); } @@ -197,6 +198,7 @@ static void block_dnode_free(dnode_t *node, next = p->next; free(p); } + free(db); free(node); } @@ -245,6 +247,7 @@ void e2fsck_pass1_dupblocks(e2fsck_t ctx, char *block_buf) */ dict_free_nodes(&ino_dict); dict_free_nodes(&blk_dict); + ext2fs_free_inode_bitmap(inode_dup_map); } /* diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c index c8a3ddb..f5a326d 100644 --- a/e2fsck/pass2.c +++ b/e2fsck/pass2.c @@ -251,6 +251,7 @@ void e2fsck_pass2(e2fsck_t ctx) dx_dir->numblocks = 0; } } + e2fsck_free_dx_dir_info(ctx); #endif ext2fs_free_mem(&buf); ext2fs_free_dblist(fs->dblist); diff --git a/e2fsck/unix.c b/e2fsck/unix.c index ffcdcc6..e118e9a 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -802,7 +802,6 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx) argv[optind]); fatal_error(ctx, 0); } - ctx->filesystem_name = string_copy(ctx, ctx->filesystem_name, 0); if (extended_opts) parse_extended_opts(ctx, extended_opts);