Do not dereference before null check.
This commit is contained in:
parent
e69c679fd9
commit
c4bb654916
|
@ -117,9 +117,11 @@ typedef struct _GPTDiskData GPTDiskData;
|
||||||
static quint64 firstUsableSector(const Device& d)
|
static quint64 firstUsableSector(const Device& d)
|
||||||
{
|
{
|
||||||
PedDevice* pedDevice = ped_device_get(d.deviceNode().toLatin1().constData());
|
PedDevice* pedDevice = ped_device_get(d.deviceNode().toLatin1().constData());
|
||||||
PedDisk* pedDisk = pedDevice ? ped_disk_new(pedDevice) : NULL;
|
PedDisk* pedDisk = pedDevice ? ped_disk_new(pedDevice) : nullptr;
|
||||||
|
|
||||||
quint64 rval = pedDisk->dev->bios_geom.sectors;
|
quint64 rval = 0;
|
||||||
|
if (pedDisk)
|
||||||
|
rval = pedDisk->dev->bios_geom.sectors;
|
||||||
|
|
||||||
if (pedDisk && strcmp(pedDisk->type->name, "gpt") == 0) {
|
if (pedDisk && strcmp(pedDisk->type->name, "gpt") == 0) {
|
||||||
GPTDiskData* gpt_disk_data = reinterpret_cast<GPTDiskData*>(pedDisk->disk_specific);
|
GPTDiskData* gpt_disk_data = reinterpret_cast<GPTDiskData*>(pedDisk->disk_specific);
|
||||||
|
@ -141,11 +143,13 @@ static quint64 firstUsableSector(const Device& d)
|
||||||
static quint64 lastUsableSector(const Device& d)
|
static quint64 lastUsableSector(const Device& d)
|
||||||
{
|
{
|
||||||
PedDevice* pedDevice = ped_device_get(d.deviceNode().toLatin1().constData());
|
PedDevice* pedDevice = ped_device_get(d.deviceNode().toLatin1().constData());
|
||||||
PedDisk* pedDisk = pedDevice ? ped_disk_new(pedDevice) : NULL;
|
PedDisk* pedDisk = pedDevice ? ped_disk_new(pedDevice) : nullptr;
|
||||||
|
|
||||||
quint64 rval = static_cast< quint64 >( pedDisk->dev->bios_geom.sectors ) *
|
quint64 rval = 0;
|
||||||
pedDisk->dev->bios_geom.heads *
|
if (pedDisk)
|
||||||
pedDisk->dev->bios_geom.cylinders - 1;
|
rval = static_cast< quint64 >( pedDisk->dev->bios_geom.sectors ) *
|
||||||
|
pedDisk->dev->bios_geom.heads *
|
||||||
|
pedDisk->dev->bios_geom.cylinders - 1;
|
||||||
|
|
||||||
if (pedDisk && strcmp(pedDisk->type->name, "gpt") == 0) {
|
if (pedDisk && strcmp(pedDisk->type->name, "gpt") == 0) {
|
||||||
GPTDiskData* gpt_disk_data = reinterpret_cast<GPTDiskData*>(pedDisk->disk_specific);
|
GPTDiskData* gpt_disk_data = reinterpret_cast<GPTDiskData*>(pedDisk->disk_specific);
|
||||||
|
|
Loading…
Reference in New Issue