[PATCH 1/3] mkfs/proto.c: avoid to use NULL pointer

zhanchengbin
2022-06-06T12:33:10Z

Change malloc to xmalloc.

Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com>
---
mkfs/proto.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mkfs/proto.c b/mkfs/proto.c
index 127d87dd..f3b8710c 100644
--- a/mkfs/proto.c
+++ b/mkfs/proto.c
@@ -70,7 +70,7 @@ setup_proto(
goto out_fail;
}

- buf = malloc(size + 1);
+ buf = xmalloc(size + 1);
if (read(fd, buf, size) < size) {
fprintf(stderr, _("%s: read failed on %s: %s\n"),
progname, fname, strerror(errno));
@@ -303,7 +303,7 @@ newregfile(
exit(1);
}
if ((*len = (int)size)) {
- buf = malloc(size);
+ buf = xmalloc(size);
if (read(fd, buf, size) < size) {
fprintf(stderr, _("%s: read failed on %s: %s\n"),
progname, fname, strerror(errno));
--
2.27.0