fix null ptr exception as reported by Coverity