Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Nov 2017 09:47:31 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r326187 - head/cddl/contrib/opensolaris/cmd/zdb
Message-ID:  <201711250947.vAP9lV0f042028@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Sat Nov 25 09:47:31 2017
New Revision: 326187
URL: https://svnweb.freebsd.org/changeset/base/326187

Log:
  zdb: follow-up to r326150, check if malloc succeeded
  
  Reported by:	rpokala
  MFC after:	1 week
  X-MFC with:	r326150

Modified:
  head/cddl/contrib/opensolaris/cmd/zdb/zdb.c

Modified: head/cddl/contrib/opensolaris/cmd/zdb/zdb.c
==============================================================================
--- head/cddl/contrib/opensolaris/cmd/zdb/zdb.c	Sat Nov 25 09:42:14 2017	(r326186)
+++ head/cddl/contrib/opensolaris/cmd/zdb/zdb.c	Sat Nov 25 09:47:31 2017	(r326187)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201711250947.vAP9lV0f042028>