mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-27 04:41:23 +00:00
more I_GetFreeMem fixes: don't attempt to set *total to 0L if total itself is NULL
This commit is contained in:
parent
1216c9da18
commit
4a0305eec8
1 changed files with 14 additions and 8 deletions
|
@ -2729,20 +2729,23 @@ UINT32 I_GetFreeMem(UINT32 *total)
|
||||||
};
|
};
|
||||||
if ((kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) == NULL)
|
if ((kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) == NULL)
|
||||||
{
|
{
|
||||||
*total = 0L;
|
if (total)
|
||||||
|
*total = 0L;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (kvm_nlist(kd, namelist) != 0)
|
if (kvm_nlist(kd, namelist) != 0)
|
||||||
{
|
{
|
||||||
kvm_close (kd);
|
kvm_close (kd);
|
||||||
*total = 0L;
|
if (total)
|
||||||
|
*total = 0L;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (kvm_read(kd, namelist[X_SUM].n_value, &sum,
|
if (kvm_read(kd, namelist[X_SUM].n_value, &sum,
|
||||||
sizeof (sum)) != sizeof (sum))
|
sizeof (sum)) != sizeof (sum))
|
||||||
{
|
{
|
||||||
kvm_close(kd);
|
kvm_close(kd);
|
||||||
*total = 0L;
|
if (total)
|
||||||
|
*total = 0L;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
kvm_close(kd);
|
kvm_close(kd);
|
||||||
|
@ -2789,25 +2792,28 @@ UINT32 I_GetFreeMem(UINT32 *total)
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
{
|
{
|
||||||
// Error
|
// Error
|
||||||
*total = 0L;
|
if (total)
|
||||||
|
*total = 0L;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf[n] = '\0';
|
buf[n] = '\0';
|
||||||
if (NULL == (memTag = strstr(buf, MEMTOTAL)))
|
if ((memTag = strstr(buf, MEMTOTAL)) == NULL)
|
||||||
{
|
{
|
||||||
// Error
|
// Error
|
||||||
*total = 0L;
|
if (total)
|
||||||
|
*total = 0L;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
memTag += sizeof (MEMTOTAL);
|
memTag += sizeof (MEMTOTAL);
|
||||||
totalKBytes = atoi(memTag);
|
totalKBytes = atoi(memTag);
|
||||||
|
|
||||||
if (NULL == (memTag = strstr(buf, MEMFREE)))
|
if ((memTag = strstr(buf, MEMFREE)) == NULL)
|
||||||
{
|
{
|
||||||
// Error
|
// Error
|
||||||
*total = 0L;
|
if (total)
|
||||||
|
*total = 0L;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue