diff options
author | Chris Dickens <christopher.a.dickens@gmail.com> | 2018-01-27 16:22:10 -0800 |
---|---|---|
committer | Chris Dickens <christopher.a.dickens@gmail.com> | 2018-01-27 16:22:10 -0800 |
commit | e5a7bb548a5c3b04a086b62de043f02fdae338b6 (patch) | |
tree | 84449a52605cdb58e8565d413d7adb149d12c6bf /libusb/os/windows_winusb.h | |
parent | 84209b4fb54ebc62f5a60f0122bddef3ebd97d0a (diff) | |
download | libusb-e5a7bb548a5c3b04a086b62de043f02fdae338b6.tar.gz |
Windows: Check composite interfaces before calling functions
Commit c4438b3c introduced a regression by failing to check for the
presence of a function in the backend when called on a composite device.
Fix this by introducing a new helper macro and checking for function
pointers at all necessary locations.
Closes #383
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Diffstat (limited to 'libusb/os/windows_winusb.h')
-rw-r--r-- | libusb/os/windows_winusb.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libusb/os/windows_winusb.h b/libusb/os/windows_winusb.h index 3bdf185..299dc6c 100644 --- a/libusb/os/windows_winusb.h +++ b/libusb/os/windows_winusb.h @@ -119,8 +119,15 @@ extern const struct windows_usb_api_backend usb_api_backend[USB_API_MAX]; #define PRINT_UNSUPPORTED_API(fname) \ usbi_dbg("unsupported API call for '%s' " \ - "(unrecognized device driver)", #fname); \ - return LIBUSB_ERROR_NOT_SUPPORTED; + "(unrecognized device driver)", #fname) + +#define CHECK_SUPPORTED_API(apip, fname) \ + do { \ + if ((apip)->fname == NULL) { \ + PRINT_UNSUPPORTED_API(fname); \ + return LIBUSB_ERROR_NOT_SUPPORTED; \ + } \ + } while (0) /* * private structures definition |