Fix null dereference issue

Coverity tells me that I was a very naughty boy.