[KERNEL32] Check for NULL lpBytesReturned

Add NULL check for lpBytesReturned to match Windows 8+ behavior, which Wine code relies on.
This commit is contained in:
Timo Kreuzer
2026-05-19 14:40:49 +00:00
parent 6ef4ddb83d
commit e1e3b8aa3d
+6 -3
View File
@@ -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);