Skip to content

Commit 10c20cc

Browse files
committed
[librpfile] RpFile_scsi_win32.cpp, rereadDeviceSizeOS(): Check d->filenameW, not d->filename.
d->filename is usually nullptr at this point on Windows. Also, ensure that d->filenameW is neither NULL nor an empty string. It shouldn't happen, but a redundant check is better than a crash. See #413: Exports/Imports table in win32 shell ext page showing blank rows Reported by @ksharperd.
1 parent ed2999e commit 10c20cc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/librpfile/scsi/RpFile_scsi_win32.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,12 @@ int RpFile::rereadDeviceSizeOS(off64_t *pDeviceSize, uint32_t *pSectorSize)
6262
DWORD dwNumberOfFreeClusters, dwTotalNumberOfClusters;
6363
DWORD w32err = 0;
6464

65-
// FIXME: What if filename is empty?
6665
RP_D(RpFile);
67-
const TCHAR drive_name[4] = {static_cast<TCHAR>(d->filename[0]), _T(':'), _T('\\'), 0};
66+
if (!d->filenameW || d->filenameW[0] == _T('\0')) {
67+
// No filename... Assume this isn't a device.
68+
return -ENODEV;
69+
}
70+
const TCHAR drive_name[4] = {static_cast<TCHAR>(d->filenameW[0]), _T(':'), _T('\\'), 0};
6871
BOOL bRet = GetDiskFreeSpace(drive_name,
6972
&dwSectorsPerCluster, &dwBytesPerSector,
7073
&dwNumberOfFreeClusters, &dwTotalNumberOfClusters);

0 commit comments

Comments
 (0)