Added missing return value.

- Coverity: 993274, 993275
Removed redundant code.

- Coverity 993252
fix possible null dereference, CID 993739
fix resource leak, CID 968209
fix resource leak, CID 989564