Re #8459. Switch to Poco::AutoPtr instead of manually releasing.

Although release was being correctly called in this case, it's better
to use AutoPtr.
Re #8459. Replace manual release() calls with Poco::AutoPtr.

There were no leaks, but this is better and exception-safe.