Fix memory leak of CGUIViewState

Follow other examples, and use auto_ptr to make sure that the ViewState
object is freed when it goes out of scope

Coverity CID 1211800
Remove null test

It doesn't add anything, and the semi-colon meant it wasn't doing the
expected thing anyway.

Fix Coverity CID 1211801
Merge pull request #4652 from cg110/CoverityFixes3

A couple of fixes from this weeks coverity scan.