diff --git a/dll/win32/kernel32/client/file/deviceio.c b/dll/win32/kernel32/client/file/deviceio.c index bfcf575618d..cdc82a82c01 100644 --- a/dll/win32/kernel32/client/file/deviceio.c +++ b/dll/win32/kernel32/client/file/deviceio.c @@ -264,13 +264,16 @@ DeviceIoControl(IN HANDLE hDevice, /* Check for success */ if (NT_SUCCESS(Status)) { - /* Return the byte count */ - *lpBytesReturned = Iosb.Information; + /* Windows 2003 and Vista do not check for lpBytesReturned == NULL, + * but Windows 8+ does. Avoid crashing. */ + if (lpBytesReturned != NULL) + *lpBytesReturned = Iosb.Information; } else { /* Check for informational or warning failure */ - if (!NT_ERROR(Status)) *lpBytesReturned = Iosb.Information; + if (!NT_ERROR(Status) && (lpBytesReturned != NULL)) + *lpBytesReturned = Iosb.Information; /* Return a failure */ BaseSetLastNTError(Status);