Check correct variable for NULL

Issue discovered by Coverity scan, CID 43163.