Skip to content

Commit

Permalink
remote: clear self handle only on error
Browse files Browse the repository at this point in the history
When setting the callbacks fails, we want to clear self._self_handle so
we don't leak a pointer to ourselves.

The current code used a 'finally' clause which clears it
unconditionally, which means that by the time the fetch starts, we have
no guarantee that the handle will be valid.

Replace that with an except and re-raise to make sure we only clear it
here if there was an error.
  • Loading branch information
carlosmn committed Sep 3, 2014
1 parent cd08425 commit 70256d1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pygit2/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,9 @@ def fetch(self, signature=None, message=None):
err = C.git_remote_set_callbacks(self._remote, callbacks)
try:
check_error(err)
finally:
except:
self._self_handle = None
raise

if signature:
ptr = signature._pointer[:]
Expand Down

0 comments on commit 70256d1

Please sign in to comment.