Commit c01bd3b4c29a5d19f09d1933b4ce45af3bf07c8b
Committed by
GitHub
Merge pull request #11 from ED6E0F17/fixes
Fix memory leak.
Showing
2 changed files
with
4 additions
and
2 deletions
Makefile
main.c
| @@ -127,7 +127,7 @@ int Initialize_Device(libusb_context ** ctx, libusb_device_handle ** usb_device) | @@ -127,7 +127,7 @@ int Initialize_Device(libusb_context ** ctx, libusb_device_handle ** usb_device) | ||
| 127 | 127 | ||
| 128 | int ep_write(void *buf, int len, libusb_device_handle * usb_device) | 128 | int ep_write(void *buf, int len, libusb_device_handle * usb_device) |
| 129 | { | 129 | { |
| 130 | - int a_len; | 130 | + int a_len = 0; |
| 131 | int ret = | 131 | int ret = |
| 132 | libusb_control_transfer(usb_device, LIBUSB_REQUEST_TYPE_VENDOR, 0, | 132 | libusb_control_transfer(usb_device, LIBUSB_REQUEST_TYPE_VENDOR, 0, |
| 133 | len & 0xffff, len >> 16, NULL, 0, 1000); | 133 | len & 0xffff, len >> 16, NULL, 0, 1000); |
| @@ -362,11 +362,13 @@ int file_server(libusb_device_handle * usb_device) | @@ -362,11 +362,13 @@ int file_server(libusb_device_handle * usb_device) | ||
| 362 | if(read != file_size) | 362 | if(read != file_size) |
| 363 | { | 363 | { |
| 364 | printf("Failed to read from input file\n"); | 364 | printf("Failed to read from input file\n"); |
| 365 | + free(buf); | ||
| 365 | return -1; | 366 | return -1; |
| 366 | } | 367 | } |
| 367 | 368 | ||
| 368 | int sz = ep_write(buf, file_size, usb_device); | 369 | int sz = ep_write(buf, file_size, usb_device); |
| 369 | 370 | ||
| 371 | + free(buf); | ||
| 370 | fclose(fp); | 372 | fclose(fp); |
| 371 | fp = NULL; | 373 | fp = NULL; |
| 372 | 374 |