e2freefrag: fix memory leak in scan_online()
PATCH 1/2 e2freefrag: fix memory leak in scan_online()
Signed-off-by Lukas Czerner <[email protected]>
--- misc/e2freefrag.c | 1 + 1 file changed, 1 insertion(+)
misc/e2freefrag.c +1 -0
@@ -236,6 +236,7 @@ static int scan_online(ext2_filsys fs, struct chunk_info *info, fsmap_advance(fsmap); } +free (fsmap);return 1 ; }#else
Signature · 1 line
2.20.1
PATCH 2/2 e2fsprogs: fix potential memory leak in path_append()
If realloc() fails in path_append() we will lose a memory pointed to by target->path. Fix it.
Signed-off-by Lukas Czerner <[email protected]>
--- misc/create_inode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
misc/create_inode.c +4 -2
@@ -704,10 +704,12 @@ struct file_info {static errcode_t path_append (struct file_info *target,const char *file) {if (strlen (file) + target->path_len +1 > target->path_max_len) { +void *p; target->path_max_len *=2 ; - target->path =realloc (target->path, target->path_max_len); -if (!target->path) + p =realloc (target->path, target->path_max_len); +if (p ==NULL )return EXT2_ET_NO_MEMORY ; + target->path = p; } target->path_len +=sprintf (target->path + target->path_len,"/%s" , file);
Signature · 1 line
2.20.1
Theodore Y. Ts'o
AppliedRe: [PATCH 2/2] e2fsprogs: fix potential memory leak in path_append()
Quoted 4 lines · Lukas Czerner
If
realloc()fails inpath_append()we will lose a memory pointed to bytarget->path. Fix it.Signed-off-by Lukas Czerner <[email protected]>
Thanks, applied.
- Ted