]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug in w32_memory_info
authorArthur Miller <arthur.miller@live.com>
Tue, 21 Jan 2025 18:10:14 +0000 (19:10 +0100)
committerEshel Yaron <me@eshelyaron.com>
Sat, 25 Jan 2025 17:42:11 +0000 (18:42 +0100)
* src/w32.c (w32_memory_info): Initialize struct size.

(cherry picked from commit 58d3d4820ad327f07cea5894a9675bf30553461e)

src/w32.c

index deeca031f64739e97efe34b549ddb9c320c5c331..927343834457aa31c76387ba200658ac91d47075 100644 (file)
--- a/src/w32.c
+++ b/src/w32.c
@@ -7681,7 +7681,7 @@ w32_memory_info (unsigned long long *totalram, unsigned long long *freeram,
 {
   MEMORYSTATUS memst;
   MEMORY_STATUS_EX memstex;
-
+  memstex.dwLength = sizeof(memstex);
   /* Use GlobalMemoryStatusEx if available, as it can report more than
      2GB of memory.  */
   if (global_memory_status_ex (&memstex))
@@ -7692,7 +7692,9 @@ w32_memory_info (unsigned long long *totalram, unsigned long long *freeram,
       *freeswap  = memstex.ullAvailPageFile;
       return 0;
     }
-  else if (global_memory_status (&memst))
+
+  memst.dwLength = sizeof(memst);
+  if (global_memory_status (&memst))
     {
       *totalram = memst.dwTotalPhys;
       *freeram   = memst.dwAvailPhys;