nv_malloc can fail in userland.

Add check to prevent a NULL pointer dereference.

Pointed out by:	mjg
Approved by:	pjd (mentor)
This commit is contained in:
oshogbo 2015-05-02 18:12:34 +00:00
parent 2cc8650d9b
commit ffeaddc43c

View File

@ -129,6 +129,8 @@ nvlist_create(int flags)
PJDLOG_ASSERT((flags & ~(NV_FLAG_PUBLIC_MASK)) == 0);
nvl = nv_malloc(sizeof(*nvl));
if (nvl == NULL)
return (NULL);
nvl->nvl_error = 0;
nvl->nvl_flags = flags;
nvl->nvl_parent = NULL;