]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - malloc/tst-memalign.c
malloc: Fix for infinite loop in memalign/posix_memalign.
[thirdparty/glibc.git] / malloc / tst-memalign.c
index 1c5975248321d5ebb2388140a6a0063186da536a..cf48e7ed1fceb2915502c63360446c3988ec2da4 100644 (file)
@@ -70,6 +70,21 @@ do_test (void)
 
   free (p);
 
+  errno = 0;
+
+  /* Test to expose integer overflow in malloc internals from BZ #16038.  */
+  p = memalign (-1, pagesize);
+
+  save = errno;
+
+  if (p != NULL)
+    merror ("memalign (-1, pagesize) succeeded.");
+
+  if (p == NULL && save != EINVAL)
+    merror ("memalign (-1, pagesize) errno is not set correctly");
+
+  free (p);
+
   /* A zero-sized allocation should succeed with glibc, returning a
      non-NULL value.  */
   p = memalign (sizeof (void *), 0);