Skip to content

Commit

Permalink
Ensure self handle stays alive - keeping it in callbacks is not enough.
Browse files Browse the repository at this point in the history
  • Loading branch information
mduggan committed Aug 25, 2014
1 parent 0813ec7 commit 2f2d400
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pygit2/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,15 @@ def fetch(self, signature=None, message=None):
callbacks.transfer_progress = self._transfer_progress_cb
callbacks.update_tips = self._update_tips_cb
callbacks.credentials = self._credentials_cb
callbacks.payload = ffi.new_handle(self)
# We need to make sure that this handle stays alive
self._self_handle = ffi.new_handle(self)
callbacks.payload = self._self_handle

err = C.git_remote_set_callbacks(self._remote, callbacks)
check_error(err)
try:
check_error(err)
finally:
self._self_handle = None

if signature:
ptr = signature._pointer[:]
Expand All @@ -223,6 +228,7 @@ def fetch(self, signature=None, message=None):
check_error(err)
finally:
# Even on error, clear stored callbacks and reset to default
self._self_handle = None
err = C.git_remote_set_callbacks(self._remote, defaultcallbacks)
check_error(err)

Expand Down

0 comments on commit 2f2d400

Please sign in to comment.