Commit 22b9bef4 authored by David Cole's avatar David Cole

Fix bogus calls to GetMemoryStatus and GetMemoryStatusEx: need to set the...

Fix bogus calls to GetMemoryStatus and GetMemoryStatusEx: need to set the dwLength member of the struct prior to calling. Otherwise it's just a garbage value from the stack. Also, pay attention to return value of GetMemoryStatusEx: if it indicates failure then just return 0 without using any of the other data the call returns.
parent bc1f7eb8
......@@ -2279,11 +2279,16 @@ int SystemInformationImplementation::QueryMemory()
#elif _WIN32
#if _MSC_VER < 1300
MEMORYSTATUS ms;
ms.dwLength = sizeof(ms);
GlobalMemoryStatus(&ms);
#define MEM_VAL(value) dw##value
#else
MEMORYSTATUSEX ms;
GlobalMemoryStatusEx(&ms);
ms.dwLength = sizeof(ms);
if (0 == GlobalMemoryStatusEx(&ms))
{
return 0;
}
#define MEM_VAL(value) ull##value
#endif
unsigned long tv = ms.MEM_VAL(TotalVirtual);
......
......@@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2009)
SET(KWSYS_DATE_STAMP_MONTH 11)
# KWSys version date day component. Format is DD.
SET(KWSYS_DATE_STAMP_DAY 16)
SET(KWSYS_DATE_STAMP_DAY 18)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment