Fix crash when SD card is smaller than starting sector of scsi disk

This commit is contained in:
Michael McMaster 2017-04-29 14:39:33 +10:00
parent 124ccf1d64
commit 63ef5824b1
2 changed files with 10 additions and 1 deletions

View File

@ -28,7 +28,16 @@ uint32_t getScsiCapacity(
uint32_t capacity =
(sdDev.capacity - sdSectorStart) /
SDSectorsPerSCSISector(bytesPerSector);
if (scsiSectors && (capacity > scsiSectors))
if (sdDev.capacity == 0)
{
capacity = 0;
}
else if (sdSectorStart >= sdDev.capacity)
{
capacity = 0;
}
else if (scsiSectors && (capacity > scsiSectors))
{
capacity = scsiSectors;
}