summaryrefslogtreecommitdiffstats
path: root/src/ifuse.c
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2008-08-12 20:42:26 +0200
committerGravatar Jonathan Beck2008-08-21 18:47:04 +0200
commite5e5f21cae73230eaaa70273bd4400ff6b86641a (patch)
tree729fe309175f6952c134e35b80e9ed79b646c135 /src/ifuse.c
parent94eca7874e2c60cad84b344feaaa66418b1b47ef (diff)
downloadlibimobiledevice-e5e5f21cae73230eaaa70273bd4400ff6b86641a.tar.gz
libimobiledevice-e5e5f21cae73230eaaa70273bd4400ff6b86641a.tar.bz2
fix some memory leaks
Diffstat (limited to 'src/ifuse.c')
-rw-r--r--src/ifuse.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/ifuse.c b/src/ifuse.c
index d35564e..7ae4827 100644
--- a/src/ifuse.c
+++ b/src/ifuse.c
@@ -42,6 +42,9 @@
42GHashTable *file_handles; 42GHashTable *file_handles;
43int fh_index = 0; 43int fh_index = 0;
44 44
45iPhone *phone = NULL;
46lockdownd_client *control = NULL;
47
45int debug = 0; 48int debug = 0;
46 49
47static int ifuse_getattr(const char *path, struct stat *stbuf) { 50static int ifuse_getattr(const char *path, struct stat *stbuf) {
@@ -175,14 +178,13 @@ static int ifuse_release(const char *path, struct fuse_file_info *fi){
175 178
176void *ifuse_init(struct fuse_conn_info *conn) { 179void *ifuse_init(struct fuse_conn_info *conn) {
177 int port = 0; 180 int port = 0;
178 char* host_id = NULL;
179 AFClient *afc = NULL; 181 AFClient *afc = NULL;
180 182
181 conn->async_read = 0; 183 conn->async_read = 0;
182 184
183 file_handles = g_hash_table_new(g_int_hash, g_int_equal); 185 file_handles = g_hash_table_new(g_int_hash, g_int_equal);
184 186
185 iPhone *phone = get_iPhone(); 187 phone = get_iPhone();
186 if (!phone){ 188 if (!phone){
187 fprintf(stderr, "No iPhone found, is it connected?\n"); 189 fprintf(stderr, "No iPhone found, is it connected?\n");
188 return NULL; 190 return NULL;
@@ -194,13 +196,10 @@ void *ifuse_init(struct fuse_conn_info *conn) {
194 return NULL; 196 return NULL;
195 } 197 }
196 198
197 host_id = get_host_id(); 199 if (!lockdownd_init(phone, &control)) {
198 if ((host_id && !lockdownd_start_SSL_session(control, host_id)) || !host_id) { 200 fprintf(stderr, "Something went wrong in the lockdownd client.\n");
199 fprintf(stderr, "Something went wrong in GnuTLS. Is your HostID configured in .config/libiphone/libiphonerc?\n");
200 return NULL; 201 return NULL;
201 } 202 }
202 free(host_id);
203 host_id = NULL;
204 203
205 port = lockdownd_start_service(control, "com.apple.afc"); 204 port = lockdownd_start_service(control, "com.apple.afc");
206 if (!port) { 205 if (!port) {
@@ -215,11 +214,10 @@ void *ifuse_init(struct fuse_conn_info *conn) {
215 214
216void ifuse_cleanup(void *data) { 215void ifuse_cleanup(void *data) {
217 AFClient *afc = (AFClient *)data; 216 AFClient *afc = (AFClient *)data;
218 if (afc) { 217
219 iPhone *phone = afc->connection->phone; 218 afc_disconnect(afc);
220 afc_disconnect(afc); 219 lockdownd_close(control);
221 free_iPhone(phone); 220 free_iPhone(phone);
222 }
223} 221}
224 222
225int ifuse_flush(const char *path, struct fuse_file_info *fi) { 223int ifuse_flush(const char *path, struct fuse_file_info *fi) {