From d2bd44d024481d13f47dece4cf165cdc4021fdb3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 18 Jan 2016 13:09:03 +0530 Subject: [PATCH] Fix NULL pointer in get_storage_number() --- src/calibre/devices/winusb.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/devices/winusb.py b/src/calibre/devices/winusb.py index 44af31ac18..7432bdec5f 100644 --- a/src/calibre/devices/winusb.py +++ b/src/calibre/devices/winusb.py @@ -386,8 +386,9 @@ def iterancestors(devinst): def get_storage_number(devpath): sdn = STORAGE_DEVICE_NUMBER() handle = CreateFile(devpath, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, None, OPEN_EXISTING, 0, None) + bytes_returned = DWORD(0) try: - DeviceIoControl(handle, IOCTL_STORAGE_GET_DEVICE_NUMBER, None, 0, byref(sdn), sizeof(STORAGE_DEVICE_NUMBER), None, None) + DeviceIoControl(handle, IOCTL_STORAGE_GET_DEVICE_NUMBER, None, 0, byref(sdn), sizeof(STORAGE_DEVICE_NUMBER), byref(bytes_returned), None) finally: CloseHandle(handle) return sdn.as_tuple()