]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
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 fb2887be81f1bd6b5dd20041eef524979941a9ac..901235c777de3fc15a40997ee53197a1aecf8610 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 eba6adda1537199e13ec44f9e64f1c73c2fbd051..5c48d3280a636e395936dacf03e87dc9875538cf 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 d08ece441984e711991dff396a9cf1bbd5db3d5f..99f0a3c12140df0fa69b0d0c9d4647b531d7476c 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 c8a3ddb4bb34b126876d21d3a1df53c9cc4aac2f..f5a326d3285823e71b5076004b2732949ea1b38a 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 ffcdcc62aa5341956d857b39edcb99fedf53c2cc..e118e9acfb1d39042a6e5a7dd45a9ec94507ad2c 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);