Check to ensure the buffer returned is not NULL.
Direct commit to the branch as this behavior is only seeing in stable/11.
Reported by: Thomas Barabosch, Fraunhofer FKIE
Reviewed by: wes@
Approved by: so
Security: FreeBSD-EN-18:10.syscall
Security: CVE-2018-17154