diff options
author | Bryan Forbes | 2010-04-30 13:35:57 -0500 |
---|---|---|
committer | Martin Szulecki | 2012-03-20 23:25:55 +0100 |
commit | 3877711296cbfa4a0bcafc3c5560609a1ce2d079 (patch) | |
tree | 751f1fd27ce3ee5d8dd9d748600381c0d2e5d6bd /cython/mobile_image_mounter.pxi | |
parent | 74943414c8e04a92f42dcbc4fac1599c7f9deed2 (diff) | |
download | libimobiledevice-3877711296cbfa4a0bcafc3c5560609a1ce2d079.tar.gz libimobiledevice-3877711296cbfa4a0bcafc3c5560609a1ce2d079.tar.bz2 |
More memory leak plugging. Some code cleanup too.
Diffstat (limited to 'cython/mobile_image_mounter.pxi')
-rw-r--r-- | cython/mobile_image_mounter.pxi | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/cython/mobile_image_mounter.pxi b/cython/mobile_image_mounter.pxi index e70cff7..bf304d4 100644 --- a/cython/mobile_image_mounter.pxi +++ b/cython/mobile_image_mounter.pxi @@ -32,11 +32,7 @@ cdef class MobileImageMounterClient(PropertyListService): cdef mobile_image_mounter_client_t _c_client def __cinit__(self, iDevice device not None, int port, *args, **kwargs): - cdef: - iDevice dev = device - mobile_image_mounter_error_t err - err = mobile_image_mounter_new(dev._c_dev, port, &self._c_client) - self.handle_error(err) + self.handle_error(mobile_image_mounter_new(device._c_dev, port, &self._c_client)) def __dealloc__(self): cdef mobile_image_mounter_error_t err @@ -52,8 +48,14 @@ cdef class MobileImageMounterClient(PropertyListService): plist.plist_t c_node = NULL mobile_image_mounter_error_t err err = mobile_image_mounter_lookup_image(self._c_client, image_type, &c_node) - self.handle_error(err) - return plist.plist_t_to_node(c_node) + + try: + self.handle_error(err) + + return plist.plist_t_to_node(c_node) + except Exception, e: + if c_node != NULL: + plist.plist_free(c_node) cpdef plist.Node mount_image(self, bytes image_path, bytes image_signature, bytes image_type): cdef: @@ -61,8 +63,14 @@ cdef class MobileImageMounterClient(PropertyListService): mobile_image_mounter_error_t err err = mobile_image_mounter_mount_image(self._c_client, image_path, image_signature, len(image_signature), image_type, &c_node) - self.handle_error(err) - return plist.plist_t_to_node(c_node) + + try: + self.handle_error(err) + + return plist.plist_t_to_node(c_node) + except Exception, e: + if c_node != NULL: + plist.plist_free(c_node) cpdef hangup(self): cdef mobile_image_mounter_error_t err |