fixed defects found by coverity scan
Merge pull request #2835 from ilya-lavrenov:defects