]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
pagealign_alloc: Fix crashes (regression 2025-09-11).
authorBruno Haible <bruno@clisp.org>
Sat, 13 Sep 2025 20:36:06 +0000 (22:36 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 13 Sep 2025 22:18:04 +0000 (00:18 +0200)
* lib/pagealign_alloc.c (pagealign_alloc, pagealign_free): Add missing
'break' statements. For PA_IMPL_VIRTUAL_ALLOC, don't use new_memnode and
get_memnode.

ChangeLog
lib/pagealign_alloc.c

index f53d4204fe2f6e4911967e497c188430c613e4d0..d585d51c4902a9ffc164c219cea5bb0d4e38a853 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-09-13  Bruno Haible  <bruno@clisp.org>
+
+       pagealign_alloc: Fix crashes (regression 2025-09-11).
+       * lib/pagealign_alloc.c (pagealign_alloc, pagealign_free): Add missing
+       'break' statements. For PA_IMPL_VIRTUAL_ALLOC, don't use new_memnode and
+       get_memnode.
+
 2025-09-13  Paul Eggert  <eggert@cs.ucla.edu>
 
        endian: port to Solaris 11.4 and macOS 15
index 28aca9baf5f35f7201e411a96f6acb7725fb2c58..0e2ccdf7e0bbeb42f2e95bb9047d1a1a497611ff 100644 (file)
@@ -61,7 +61,7 @@ typedef union
      For each memory region, we store the original pointer returned by
      malloc().  */
   void *pointer;
-  /* For PA_IMPL_MMAP, PA_IMPL_VIRTUAL_ALLOC:
+  /* For PA_IMPL_MMAP:
      For each memory region, we store its size.  */
   size_t size;
 } info_t;
@@ -215,9 +215,7 @@ pagealign_alloc (size_t size)
           errno = ENOMEM;
           return NULL;
         }
-      info_t info;
-      info.size = size;
-      new_memnode (ret, info);
+      break;
       #else
       errno = ENOSYS;
       return NULL;
@@ -261,6 +259,7 @@ pagealign_free (void *aligned_ptr)
       #if HAVE_SYS_MMAN_H
       if (munmap (aligned_ptr, get_memnode (aligned_ptr).size) < 0)
         error (EXIT_FAILURE, errno, "Failed to unmap memory");
+      break;
       #else
       abort ();
       #endif
@@ -268,6 +267,7 @@ pagealign_free (void *aligned_ptr)
     case PA_IMPL_POSIX_MEMALIGN:
       #if HAVE_POSIX_MEMALIGN
       free (aligned_ptr);
+      break;
       #else
       abort ();
       #endif
@@ -277,6 +277,7 @@ pagealign_free (void *aligned_ptr)
       /* Documentation:
          <https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/aligned-free>  */
       _aligned_free (aligned_ptr);
+      break;
       #else
       abort ();
       #endif
@@ -285,8 +286,9 @@ pagealign_free (void *aligned_ptr)
       #if defined _WIN32 && !defined __CYGWIN__
       /* Documentation:
          <https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualfree>  */
-      if (!VirtualFree (aligned_ptr, get_memnode (aligned_ptr).size, MEM_RELEASE))
+      if (!VirtualFree (aligned_ptr, 0, MEM_RELEASE))
         error (EXIT_FAILURE, 0, "Failed to free memory");
+      break;
       #else
       abort ();
       #endif