Fixed high impact coverity issues

CID: 12462, 12223