wrong placemennt of memory free (detected already by nealey on the additional method)

This commit is contained in:
JosepMaJAZ 2017-03-19 21:44:08 +01:00
parent 037dc94312
commit f3700b75fa
1 changed files with 6 additions and 5 deletions

11
usb.c
View File

@ -98,7 +98,7 @@ usb_initiate_transfer_additional()
libusb_submit_transfer(xfer_in2); libusb_submit_transfer(xfer_in2);
} }
void void LIBUSB_CALL
usb_xfer_done(struct libusb_transfer *xfer) usb_xfer_done(struct libusb_transfer *xfer)
{ {
uint8_t *data = xfer->buffer; uint8_t *data = xfer->buffer;
@ -108,15 +108,16 @@ usb_xfer_done(struct libusb_transfer *xfer)
usb_debug_msg("Receiving", dev_info->ep_in, data, datalen); usb_debug_msg("Receiving", dev_info->ep_in, data, datalen);
alsa_write(data, datalen); alsa_write(data, datalen);
} }
free(data);
libusb_free_transfer(xfer);
if ( xfer->status == LIBUSB_TRANSFER_COMPLETED ) { if ( xfer->status == LIBUSB_TRANSFER_COMPLETED ) {
usb_initiate_transfer(); usb_initiate_transfer();
} else if ( xfer->status != LIBUSB_TRANSFER_CANCELLED ) { } else if ( xfer->status != LIBUSB_TRANSFER_CANCELLED ) {
fatal("Stopping EP_IN, because of status %d.\nSoftware needs restarting", xfer->status); fatal("Stopping EP_IN, because of status %d.\nSoftware needs restarting", xfer->status);
} }
free(data);
libusb_free_transfer(xfer);
} }
void void LIBUSB_CALL
usb_xfer_done_additional(struct libusb_transfer *xfer) usb_xfer_done_additional(struct libusb_transfer *xfer)
{ {
if ( xfer->status == LIBUSB_TRANSFER_COMPLETED ) { if ( xfer->status == LIBUSB_TRANSFER_COMPLETED ) {
@ -313,7 +314,7 @@ usb_check_fds(fd_set *rfds, fd_set *wfds)
} }
void void LIBUSB_CALL
usb_write_done(struct libusb_transfer *xfer) usb_write_done(struct libusb_transfer *xfer)
{ {
if ( xfer->status == LIBUSB_TRANSFER_TIMED_OUT ) { if ( xfer->status == LIBUSB_TRANSFER_TIMED_OUT ) {