summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Christophe Fergeau2008-08-12 23:03:00 +0200
committerGravatar Jonathan Beck2008-08-21 19:01:35 +0200
commitae11cc812ed4e4ec011a960b77973e66a8694d10 (patch)
treef4c08288e04875bf511d53e6e74dc9c26517d4c3 /src
parentf526a360da6aba9a015a1685db03d587ab7c4dbe (diff)
downloadlibimobiledevice-ae11cc812ed4e4ec011a960b77973e66a8694d10.tar.gz
libimobiledevice-ae11cc812ed4e4ec011a960b77973e66a8694d10.tar.bz2
Don't leak "response" in mux_connect
Diffstat (limited to 'src')
-rw-r--r--src/usbmux.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/usbmux.c b/src/usbmux.c
index 511bb01..a71439d 100644
--- a/src/usbmux.c
+++ b/src/usbmux.c
@@ -122,8 +122,6 @@ usbmux_connection *mux_connect(iPhone *phone, uint16 s_port, uint16 d_port) {
122 // Initialize connection stuff 122 // Initialize connection stuff
123 usbmux_connection *new_connection = (usbmux_connection*)malloc(sizeof(usbmux_connection)); 123 usbmux_connection *new_connection = (usbmux_connection*)malloc(sizeof(usbmux_connection));
124 new_connection->header = new_mux_packet(s_port, d_port); 124 new_connection->header = new_mux_packet(s_port, d_port);
125 usbmux_tcp_header *response;
126 response = (usbmux_tcp_header*)malloc(sizeof(usbmux_tcp_header));
127 // blargg 125 // blargg
128 if (new_connection && new_connection->header) { 126 if (new_connection && new_connection->header) {
129 new_connection->header->tcp_flags = 0x02; 127 new_connection->header->tcp_flags = 0x02;
@@ -131,9 +129,14 @@ usbmux_connection *mux_connect(iPhone *phone, uint16 s_port, uint16 d_port) {
131 new_connection->header->length16 = htons(new_connection->header->length16); 129 new_connection->header->length16 = htons(new_connection->header->length16);
132 130
133 if (send_to_phone(phone, (char*)new_connection->header, sizeof(usbmux_tcp_header)) >= 0) { 131 if (send_to_phone(phone, (char*)new_connection->header, sizeof(usbmux_tcp_header)) >= 0) {
132 usbmux_tcp_header *response;
133 response = (usbmux_tcp_header*)malloc(sizeof(usbmux_tcp_header));
134 bytes = recv_from_phone(phone, (char*)response, sizeof(*response)); 134 bytes = recv_from_phone(phone, (char*)response, sizeof(*response));
135 if (response->tcp_flags != 0x12) return NULL; 135 if (response->tcp_flags != 0x12) {
136 else { 136 free(response);
137 return NULL;
138 } else {
139 free(response);
137 if (debug) printf("mux_connect: connection success\n"); 140 if (debug) printf("mux_connect: connection success\n");
138 new_connection->header->tcp_flags = 0x10; 141 new_connection->header->tcp_flags = 0x10;
139 new_connection->header->scnt = 1; 142 new_connection->header->scnt = 1;