Clear out the returned table reference in all cases so we don't have
garbage in the caller.
Don't release a table unless we actually got a table.

Don't allocate a buffer until we get a table, getting a table is what
will fail.