remote: clear self handle only on error

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.
This commit is contained in:
Carlos Martín Nieto
2014-09-03 19:06:34 +02:00
parent cd08425927
commit 70256d1a00

View File

@@ -210,8 +210,9 @@ class Remote(object):
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[:]