From 718cb91ccc3fd19d4da7bc4c90a4b7d13625e662 Mon Sep 17 00:00:00 2001 From: Andriy Gapon Date: Sat, 25 Nov 2017 09:47:31 +0000 Subject: [PATCH] zdb: follow-up to r326150, check if malloc succeeded Reported by: rpokala MFC after: 1 week X-MFC with: r326150 --- cddl/contrib/opensolaris/cmd/zdb/zdb.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cddl/contrib/opensolaris/cmd/zdb/zdb.c b/cddl/contrib/opensolaris/cmd/zdb/zdb.c index f588caaf205b..186f7d2efe38 100644 --- a/cddl/contrib/opensolaris/cmd/zdb/zdb.c +++ b/cddl/contrib/opensolaris/cmd/zdb/zdb.c @@ -3739,6 +3739,11 @@ zdb_embedded_block(char *thing) } ASSERT3U(BPE_GET_LSIZE(&bp), <=, SPA_MAXBLOCKSIZE); buf = malloc(SPA_MAXBLOCKSIZE); + if (buf == NULL) { + (void) fprintf(stderr, "%s: failed to allocate %llu bytes\n", + __func__, SPA_MAXBLOCKSIZE); + exit(1); + } err = decode_embedded_bp(&bp, buf, BPE_GET_LSIZE(&bp)); if (err != 0) { (void) printf("decode failed: %u\n", err);