summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Christophe Fergeau2008-08-12 22:01:18 +0200
committerGravatar Jonathan Beck2008-08-21 18:58:17 +0200
commit0496edd88632b0bf83a78bbf5f665569f5b71e1a (patch)
tree57af5ead86b0430228b13f6439bcd74bb6af710e /src
parent877fd5089abaa58273c6b251f9ca30c4303e3632 (diff)
downloadlibimobiledevice-0496edd88632b0bf83a78bbf5f665569f5b71e1a.tar.gz
libimobiledevice-0496edd88632b0bf83a78bbf5f665569f5b71e1a.tar.bz2
Don't leak "version" in get_iPhone
Diffstat (limited to 'src')
-rw-r--r--src/iphone.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/iphone.c b/src/iphone.c
index 2bdb5c8..ecbb751 100644
--- a/src/iphone.c
+++ b/src/iphone.c
@@ -36,7 +36,6 @@ extern int debug;
36 */ 36 */
37iPhone *get_iPhone() { 37iPhone *get_iPhone() {
38 iPhone *phone = (iPhone*)malloc(sizeof(iPhone)); 38 iPhone *phone = (iPhone*)malloc(sizeof(iPhone));
39 usbmux_version_header *version = version_header();
40 struct usb_bus *bus, *busses; 39 struct usb_bus *bus, *busses;
41 struct usb_device *dev; 40 struct usb_device *dev;
42 41
@@ -79,6 +78,7 @@ iPhone *get_iPhone() {
79 78
80 // Send the version command to the phone 79 // Send the version command to the phone
81 int bytes = 0; 80 int bytes = 0;
81 usbmux_version_header *version = version_header();
82 bytes = usb_bulk_write(phone->device, BULKOUT, (char*)version, sizeof(*version), 800); 82 bytes = usb_bulk_write(phone->device, BULKOUT, (char*)version, sizeof(*version), 800);
83 if (bytes < 20 && debug) { 83 if (bytes < 20 && debug) {
84 fprintf(stderr, "get_iPhone(): libusb did NOT send enough!\n"); 84 fprintf(stderr, "get_iPhone(): libusb did NOT send enough!\n");
@@ -93,6 +93,7 @@ iPhone *get_iPhone() {
93 93
94 // Check for bad response 94 // Check for bad response
95 if (bytes < 20) { 95 if (bytes < 20) {
96 free(version);
96 free_iPhone(phone); 97 free_iPhone(phone);
97 free(version); 98 free(version);
98 if (debug) fprintf(stderr, "get_iPhone(): Invalid version message -- header too short.\n"); 99 if (debug) fprintf(stderr, "get_iPhone(): Invalid version message -- header too short.\n");
@@ -114,7 +115,6 @@ iPhone *get_iPhone() {
114 if (debug) fprintf(stderr, "get_iPhone(): Received a bad header/invalid version number."); 115 if (debug) fprintf(stderr, "get_iPhone(): Received a bad header/invalid version number.");
115 return NULL; 116 return NULL;
116 } 117 }
117
118 118
119 // If it got to this point it's gotta be bad 119 // If it got to this point it's gotta be bad
120 if (debug) fprintf(stderr, "get_iPhone(): Unknown error.\n"); 120 if (debug) fprintf(stderr, "get_iPhone(): Unknown error.\n");