kernel32: Avoid truncating 64-bit ullTotalPhys value to 32 bits when copying to ullAvailPhys, ullTotalPageFile, and ullAvailPageFile.

This commit is contained in:
Ken Thomases 2014-02-16 20:43:32 -06:00 committed by Alexandre Julliard
parent 89a96db01f
commit c91dd24098
1 changed files with 7 additions and 5 deletions

View File

@ -1226,11 +1226,13 @@ BOOL WINAPI GlobalMemoryStatusEx( LPMEMORYSTATUSEX lpmemex )
lpmemex->ullTotalPhys = val;
mib[1] = HW_USERMEM;
size_sys = sizeof(val);
if (sysctl(mib, 2, &val, &size_sys, NULL, 0) || size_sys != sizeof(val) || !val)
val = lpmemex->ullTotalPhys;
lpmemex->ullAvailPhys = val;
lpmemex->ullTotalPageFile = val;
lpmemex->ullAvailPageFile = val;
if (!sysctl(mib, 2, &val, &size_sys, NULL, 0) && size_sys == sizeof(val) && val)
lpmemex->ullAvailPhys = val;
else
lpmemex->ullAvailPhys = lpmemex->ullTotalPhys;
lpmemex->ullTotalPageFile = lpmemex->ullAvailPhys;
lpmemex->ullAvailPageFile = lpmemex->ullAvailPhys;
#elif defined ( sun )
pagesize=sysconf(_SC_PAGESIZE);
maxpages=sysconf(_SC_PHYS_PAGES);