diff --git a/usr.sbin/boot0cfg/boot0cfg.c b/usr.sbin/boot0cfg/boot0cfg.c index 2602e5075494..20b615a218ca 100644 --- a/usr.sbin/boot0cfg/boot0cfg.c +++ b/usr.sbin/boot0cfg/boot0cfg.c @@ -337,6 +337,8 @@ read_mbr(const char *disk, u_int8_t **mbr, int check_version) return (mbr_size); } *mbr = malloc(sizeof(buf)); + if (mbr == NULL) + errx(1, "%s: unable to allocate MBR buffer", disk); memcpy(*mbr, buf, sizeof(buf)); close(fd);