Release the savepoint on errors.
Release the savepoint on errors.

It fixes the "can not start transaction within transaction" and "can not detach
database while a transaction is active" errors.
While I'm here, fix a memleak.

junovitch/pkg,skoef/pkg,skoef/pkg,Open343/pkg,junovitch/pkg,khorben/pkg,en90/pkg,Open343/pkg,khorben/pkg,en90/pkg,khorben/pkg