Do not bzero() NULL pointer on malloc() error.

Submitted by:	Dmitry Luhtionov
This commit is contained in:
Alexander Motin 2010-07-14 15:14:00 +00:00
parent b744190698
commit bb160d3d4b

View File

@ -459,9 +459,9 @@ virstor_label(struct gctl_req *req)
strlcpy(md.provider, name, sizeof(md.provider));
}
sect = malloc(ssize);
bzero(sect, ssize);
if (sect == NULL)
err(1, "Cannot allocate sector of %zu bytes", ssize);
bzero(sect, ssize);
virstor_metadata_encode(&md, sect);
error = my_g_metadata_store(name, sect, ssize);
free(sect);