fix null ptr exception as reported by Coverity
Merge pull request #327 from parrt/master

fix null ptr exception as reported by Coverity