Commit c01bd3b4c29a5d19f09d1933b4ce45af3bf07c8b

Authored by Gordon Hollingworth
Committed by GitHub
2 parents 20a3c873 96fc04cb

Merge pull request #11 from ED6E0F17/fixes

Fix memory leak.
Showing 2 changed files with 4 additions and 2 deletions
Makefile
1 1 rpiboot: main.c
2   - $(CC) -g -o $@ $< -lusb-1.0
  2 + $(CC) -Wall -Wextra -g -o $@ $< -lusb-1.0
3 3  
4 4 uninstall:
5 5 rm -f /usr/bin/rpiboot
... ...
... ... @@ -127,7 +127,7 @@ int Initialize_Device(libusb_context ** ctx, libusb_device_handle ** usb_device)
127 127  
128 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 131 int ret =
132 132 libusb_control_transfer(usb_device, LIBUSB_REQUEST_TYPE_VENDOR, 0,
133 133 len & 0xffff, len >> 16, NULL, 0, 1000);
... ... @@ -362,11 +362,13 @@ int file_server(libusb_device_handle * usb_device)
362 362 if(read != file_size)
363 363 {
364 364 printf("Failed to read from input file\n");
  365 + free(buf);
365 366 return -1;
366 367 }
367 368  
368 369 int sz = ep_write(buf, file_size, usb_device);
369 370  
  371 + free(buf);
370 372 fclose(fp);
371 373 fp = NULL;
372 374  
... ...