Fixed division by zero in urbdrc

This commit is contained in:
akallabeth 2022-10-13 08:27:41 +02:00 committed by akallabeth
parent 0629bb9c20
commit b54ca508ac
1 changed files with 9 additions and 3 deletions

View File

@ -1231,12 +1231,18 @@ static int libusb_udev_isoch_transfer(IUDEVICE* idev, GENERIC_CHANNEL_CALLBACK*
if (!Buffer)
Stream_Seek(user_data->data, (NumberOfPackets * 12));
iso_packet_size = BufferSize / NumberOfPackets;
iso_transfer = libusb_alloc_transfer((int)NumberOfPackets);
if (NumberOfPackets > 0)
{
iso_packet_size = BufferSize / NumberOfPackets;
iso_transfer = libusb_alloc_transfer((int)NumberOfPackets);
}
if (iso_transfer == NULL)
{
WLog_Print(urbdrc->log, WLOG_ERROR, "Error: libusb_alloc_transfer.");
WLog_Print(urbdrc->log, WLOG_ERROR,
"Error: libusb_alloc_transfer [NumberOfPackets=%" PRIu32 ", BufferSize=%" PRIu32
" ]",
NumberOfPackets, BufferSize);
async_transfer_user_data_free(user_data);
return -1;
}