Fixed defects from coverity scan

http://i.imgur.com/QSQiJHv.png