Set `iterator` to NULL after freeing it

This prevents us from trying to free it again (line 287).

See #1.