fix potential dereference of null pointer. thanks scan-build.