more I_GetFreeMem fixes: don't attempt to set *total to 0L if total itself is NULL

This commit is contained in:
Monster Iestyn 2018-02-23 20:40:19 +00:00
parent 1216c9da18
commit 4a0305eec8

View file

@ -2729,12 +2729,14 @@ UINT32 I_GetFreeMem(UINT32 *total)
};
if ((kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) == NULL)
{
if (total)
*total = 0L;
return 0;
}
if (kvm_nlist(kd, namelist) != 0)
{
kvm_close (kd);
if (total)
*total = 0L;
return 0;
}
@ -2742,6 +2744,7 @@ UINT32 I_GetFreeMem(UINT32 *total)
sizeof (sum)) != sizeof (sum))
{
kvm_close(kd);
if (total)
*total = 0L;
return 0;
}
@ -2789,14 +2792,16 @@ UINT32 I_GetFreeMem(UINT32 *total)
if (n < 0)
{
// Error
if (total)
*total = 0L;
return 0;
}
buf[n] = '\0';
if (NULL == (memTag = strstr(buf, MEMTOTAL)))
if ((memTag = strstr(buf, MEMTOTAL)) == NULL)
{
// Error
if (total)
*total = 0L;
return 0;
}
@ -2804,9 +2809,10 @@ UINT32 I_GetFreeMem(UINT32 *total)
memTag += sizeof (MEMTOTAL);
totalKBytes = atoi(memTag);
if (NULL == (memTag = strstr(buf, MEMFREE)))
if ((memTag = strstr(buf, MEMFREE)) == NULL)
{
// Error
if (total)
*total = 0L;
return 0;
}