e2fsprogs/SOURCES/e2fsprogs-1.45.5-e2fsck-fix...

33 lines
926 B
Diff

From 4215866fa515f8f319ae602797984289248d8bfe Mon Sep 17 00:00:00 2001
From: Wang Shilong <wshilong@ddn.com>
Date: Tue, 26 Nov 2019 18:03:58 +0900
Subject: [PATCH] e2fsck: fix to return ENOMEM in alloc_size_dir()
Two memory allocation return check is missed.
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
e2fsck/rehash.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c
index e0764d0b..54bc6803 100644
--- a/e2fsck/rehash.c
+++ b/e2fsck/rehash.c
@@ -276,7 +276,11 @@ static errcode_t alloc_size_dir(ext2_filsys fs, struct out_dir *outdir,
outdir->hashes = new_mem;
} else {
outdir->buf = malloc(blocks * fs->blocksize);
+ if (!outdir->buf)
+ return ENOMEM;
outdir->hashes = malloc(blocks * sizeof(ext2_dirhash_t));
+ if (!outdir->hashes)
+ return ENOMEM;
outdir->num = 0;
}
outdir->max = blocks;
--
2.21.1