diff --git a/WinUSBNet/USBDevice.cs b/WinUSBNet/USBDevice.cs index 8255182..438b39e 100644 --- a/WinUSBNet/USBDevice.cs +++ b/WinUSBNet/USBDevice.cs @@ -254,14 +254,12 @@ public IAsyncResult BeginControlTransfer(byte requestType, byte request, int val } catch (API.APIException e) { - if (result != null) - result.Dispose(); - throw new USBException("Asynchronous control transfer failed", e); + result.Dispose(); + throw new USBException("Asynchronous control transfer failed", e); } catch (Exception) { - if (result != null) - result.Dispose(); + result.Dispose(); throw; } return result; diff --git a/WinUSBNet/USBPipe.cs b/WinUSBNet/USBPipe.cs index 1506021..98c9758 100644 --- a/WinUSBNet/USBPipe.cs +++ b/WinUSBNet/USBPipe.cs @@ -179,14 +179,12 @@ public IAsyncResult BeginRead(byte[] buffer, int offset, int length, AsyncCallba } catch (API.APIException e) { - if (result != null) - result.Dispose(); + result.Dispose(); throw new USBException("Failed to read from pipe.", e); } catch (Exception) { - if (result != null) - result.Dispose(); + result.Dispose(); throw; } return result; @@ -282,14 +280,12 @@ public IAsyncResult BeginWrite(byte[] buffer, int offset, int length, AsyncCallb } catch (API.APIException e) { - if (result != null) - result.Dispose(); + result.Dispose(); throw new USBException("Failed to write to pipe.", e); } catch (Exception) { - if (result != null) - result.Dispose(); + result.Dispose(); throw; } return result;