From 9c7da963bc8b3df8f3ed3865f00dd7c483267ac0 Mon Sep 17 00:00:00 2001 From: shpala Date: Tue, 12 Jun 2018 13:36:05 -0700 Subject: [PATCH] Fix a crash in WinEnvIO::GetSectorSize (#3975) Summary: Fix a crash in `WinEnvIO::GetSectorSize` that happens on old Windows systems (e.g Windows 7). On old Windows systems that don't support querying StorageAccessAlignmentProperty using IOCTL_STORAGE_QUERY_PROPERTY, the flow calls a different DeviceIoControl with nullptr as lpBytesReturned. When the code reaches this point, we get an access violation. Closes https://github.com/facebook/rocksdb/pull/3975 Differential Revision: D8385186 Pulled By: ajkr fbshipit-source-id: fae4c9b4b0a52c8a10182e1b35bcaa30dc393bbb --- port/win/env_win.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/port/win/env_win.cc b/port/win/env_win.cc index 3bce0d52f..4ee200626 100644 --- a/port/win/env_win.cc +++ b/port/win/env_win.cc @@ -1097,7 +1097,7 @@ size_t WinEnvIO::GetSectorSize(const std::string& fname) { DISK_GEOMETRY_EX geometry = { 0 }; ret = DeviceIoControl(hDevice, IOCTL_DISK_GET_DRIVE_GEOMETRY, - nullptr, 0, &geometry, sizeof(geometry), nullptr, nullptr); + nullptr, 0, &geometry, sizeof(geometry), &output_bytes, nullptr); if (ret) { sector_size = geometry.Geometry.BytesPerSector; }