Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Side by Side Diff: patches/16_fix_leaks.patch

Issue 12041060: libmtp: Fix some leaks in common code paths. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libmtp/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/libmtp.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 Index: src/libmtp.c
2 ===================================================================
3 --- src/libmtp.c (revision 178434)
4 +++ src/libmtp.c (working copy)
5 @@ -1778,6 +1778,8 @@
6 char *minorstr = strndup(element + i + 1, strlen(element) - i - 1);
7 major = atoi(majorstr);
8 minor = atoi(minorstr);
9 + free(majorstr);
10 + free(minorstr);
11 extension = malloc(sizeof(LIBMTP_device_extension_t));
12 extension->name = name;
13 extension->major = major;
14 Index: src/libusb1-glue.c
15 ===================================================================
16 --- src/libusb1-glue.c (revision 178434)
17 +++ src/libusb1-glue.c (working copy)
18 @@ -541,6 +541,7 @@
19 }
20 }
21 }
22 + libusb_free_device_list (devs, 0);
23
24 /* If nothing was found we end up here. */
25 if(*mtp_device_list == NULL) {
26 @@ -969,8 +970,10 @@
27 }
28 }
29 int getfunc_ret = handler->getfunc(NULL, handler->priv,towrite,bytes,&towri te);
30 - if (getfunc_ret != PTP_RC_OK)
31 + if (getfunc_ret != PTP_RC_OK) {
32 + free(bytes);
33 return getfunc_ret;
34 + }
35 while (usbwritten < towrite) {
36 ret = USB_BULK_WRITE(ptp_usb->handle,
37 ptp_usb->outep,
38 @@ -982,6 +985,7 @@
39 LIBMTP_USB_DEBUG("USB OUT==>\n");
40
41 if (ret != LIBUSB_SUCCESS) {
42 + free(bytes);
43 return PTP_ERROR_IO;
44 }
45 LIBMTP_USB_DATA(bytes+usbwritten, xwritten, 16);
46 @@ -1004,6 +1008,7 @@
47 ptp_usb->current_transfer_total ,
48 ptp_usb->current_transfer_callb ack_data);
49 if (ret != 0) {
50 + free(bytes);
51 return PTP_ERROR_CANCEL;
52 }
53 }
54 @@ -2036,6 +2041,7 @@
55 /* Attempt to initialize this device */
56 if (init_ptp_usb(params, ptp_usb, ldevice) < 0) {
57 LIBMTP_ERROR("LIBMTP PANIC: Unable to initialize device\n");
58 + libusb_free_device_list (devs, 0);
59 return LIBMTP_ERROR_CONNECTING;
60 }
61
62 @@ -2051,12 +2057,14 @@
63
64 if(init_ptp_usb(params, ptp_usb, ldevice) <0) {
65 LIBMTP_ERROR("LIBMTP PANIC: Could not init USB on second attempt\n");
66 + libusb_free_device_list (devs, 0);
67 return LIBMTP_ERROR_CONNECTING;
68 }
69
70 /* Device has been reset, try again */
71 if ((ret = ptp_opensession(params, 1)) == PTP_ERROR_IO) {
72 LIBMTP_ERROR("LIBMTP PANIC: failed to open session on second attempt\n");
73 + libusb_free_device_list (devs, 0);
74 return LIBMTP_ERROR_CONNECTING;
75 }
76 }
77 @@ -2073,11 +2081,13 @@
78 "(Return code %d)\n Try to reset the device.\n",
79 ret);
80 libusb_release_interface(ptp_usb->handle, ptp_usb->interface);
81 + libusb_free_device_list (devs, 0);
82 return LIBMTP_ERROR_CONNECTING;
83 }
84
85 /* OK configured properly */
86 *usbinfo = (void *) ptp_usb;
87 + libusb_free_device_list (devs, 0);
88 return LIBMTP_ERROR_NONE;
89 }
90
OLDNEW
« no previous file with comments | « no previous file | src/libmtp.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698