summaryrefslogtreecommitdiffstats
path: root/src
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
parent94eca7874e2c60cad84b344feaaa66418b1b47ef (diff)
downloadlibplist-e5e5f21cae73230eaaa70273bd4400ff6b86641a.tar.gz
libplist-e5e5f21cae73230eaaa70273bd4400ff6b86641a.tar.bz2
fix some memory leaks
Diffstat (limited to 'src')
-rw-r--r--src/ifuse.c22
-rw-r--r--src/lockdown.c3
-rw-r--r--src/main.c3
3 files changed, 15 insertions, 13 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 @@
GHashTable *file_handles;
int fh_index = 0;
+iPhone *phone = NULL;
+lockdownd_client *control = NULL;
+
int debug = 0;
static 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){
void *ifuse_init(struct fuse_conn_info *conn) {
int port = 0;
- char* host_id = NULL;
AFClient *afc = NULL;
conn->async_read = 0;
file_handles = g_hash_table_new(g_int_hash, g_int_equal);
- iPhone *phone = get_iPhone();
+ phone = get_iPhone();
if (!phone){
fprintf(stderr, "No iPhone found, is it connected?\n");
return NULL;
@@ -194,13 +196,10 @@ void *ifuse_init(struct fuse_conn_info *conn) {
return NULL;
}
- host_id = get_host_id();
- if ((host_id && !lockdownd_start_SSL_session(control, host_id)) || !host_id) {
- fprintf(stderr, "Something went wrong in GnuTLS. Is your HostID configured in .config/libiphone/libiphonerc?\n");
+ if (!lockdownd_init(phone, &control)) {
+ fprintf(stderr, "Something went wrong in the lockdownd client.\n");
return NULL;
}
- free(host_id);
- host_id = NULL;
port = lockdownd_start_service(control, "com.apple.afc");
if (!port) {
@@ -215,11 +214,10 @@ void *ifuse_init(struct fuse_conn_info *conn) {
void ifuse_cleanup(void *data) {
AFClient *afc = (AFClient *)data;
- if (afc) {
- iPhone *phone = afc->connection->phone;
- afc_disconnect(afc);
- free_iPhone(phone);
- }
+
+ afc_disconnect(afc);
+ lockdownd_close(control);
+ free_iPhone(phone);
}
int ifuse_flush(const char *path, struct fuse_file_info *fi) {
diff --git a/src/lockdown.c b/src/lockdown.c
index 3969868..f02e783 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -89,11 +89,12 @@ lockdownd_client *new_lockdownd_client(iPhone *phone) {
return control;
}
+
/** Closes the lockdownd client and does the necessary housekeeping.
*
* @param control The lockdown client
*/
-void lockdown_close(lockdownd_client *control) {
+void lockdownd_close(lockdownd_client *control) {
if (!control) return;
if (control->connection) {
mux_close_connection(control->connection);
diff --git a/src/main.c b/src/main.c
index 0267dee..f7f8a2c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -131,6 +131,9 @@ int main(int argc, char *argv[]) {
printf("Start service failure.\n");
}
+ printf("All done.\n");
+
+ lockdownd_close(control);
free_iPhone(phone);
return 0;