Whamcloud - gitweb
e2fsck: fix miscellaneous memory leaks
authorTheodore Ts'o <tytso@mit.edu>
Mon, 15 Jun 2009 07:50:07 +0000 (03:50 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 15 Jun 2009 07:54:06 +0000 (03:54 -0400)
Fix various miscellaneous memory leaks which were discovered using valgrind.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck/dirinfo.c
e2fsck/dx_dirinfo.c
e2fsck/pass1b.c
e2fsck/pass2.c
e2fsck/unix.c

index fb2887b..901235c 100644 (file)
@@ -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);
index eba6add..5c48d32 100644 (file)
@@ -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;
index d08ece4..99f0a3c 100644 (file)
@@ -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);
 }
 
 /*
index c8a3ddb..f5a326d 100644 (file)
@@ -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);
index ffcdcc6..e118e9a 100644 (file)
@@ -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);