[Cmake-commits] [cmake-commits] david.cole committed SystemInformation.cxx 1.52 1.53
cmake-commits at cmake.org
cmake-commits at cmake.org
Wed Nov 18 11:22:40 EST 2009
Update of /cvsroot/CMake/CMake/Source/kwsys
In directory public:/mounts/ram/cvs-serv32367
Modified Files:
SystemInformation.cxx
Log Message:
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.
Index: SystemInformation.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/SystemInformation.cxx,v
retrieving revision 1.52
retrieving revision 1.53
diff -C 2 -d -r1.52 -r1.53
*** SystemInformation.cxx 16 Nov 2009 17:43:43 -0000 1.52
--- SystemInformation.cxx 18 Nov 2009 16:22:38 -0000 1.53
***************
*** 2280,2288 ****
#if _MSC_VER < 1300
MEMORYSTATUS ms;
GlobalMemoryStatus(&ms);
#define MEM_VAL(value) dw##value
#else
MEMORYSTATUSEX ms;
! GlobalMemoryStatusEx(&ms);
#define MEM_VAL(value) ull##value
#endif
--- 2280,2293 ----
#if _MSC_VER < 1300
MEMORYSTATUS ms;
+ ms.dwLength = sizeof(ms);
GlobalMemoryStatus(&ms);
#define MEM_VAL(value) dw##value
#else
MEMORYSTATUSEX ms;
! ms.dwLength = sizeof(ms);
! if (0 == GlobalMemoryStatusEx(&ms))
! {
! return 0;
! }
#define MEM_VAL(value) ull##value
#endif
More information about the Cmake-commits
mailing list