iterator: destroy if we couldn't create a cursor
test: Fix 'free' warning