diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/regress/lib/libc/malloc/malloc_errs/malloc_errs.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/regress/lib/libc/malloc/malloc_errs/malloc_errs.c b/src/regress/lib/libc/malloc/malloc_errs/malloc_errs.c index c711980861..486c247f0d 100644 --- a/src/regress/lib/libc/malloc/malloc_errs/malloc_errs.c +++ b/src/regress/lib/libc/malloc/malloc_errs/malloc_errs.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: malloc_errs.c,v 1.4 2023/10/22 12:20:07 otto Exp $ */ | 1 | /* $OpenBSD: malloc_errs.c,v 1.5 2024/04/14 17:47:41 otto Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2023 Otto Moerbeek <otto@drijf.net> | 3 | * Copyright (c) 2023 Otto Moerbeek <otto@drijf.net> |
| 4 | * | 4 | * |
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <err.h> | 20 | #include <err.h> |
| 21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
| 22 | #include <stdio.h> | 22 | #include <stdio.h> |
| 23 | #include <stdint.h> | ||
| 23 | #include <signal.h> | 24 | #include <signal.h> |
| 24 | #include <unistd.h> | 25 | #include <unistd.h> |
| 25 | 26 | ||
| @@ -231,7 +232,16 @@ void | |||
| 231 | t22(void) | 232 | t22(void) |
| 232 | { | 233 | { |
| 233 | int i, j; | 234 | int i, j; |
| 234 | unsigned char *p = malloc(32); | 235 | unsigned char *p; |
| 236 | while (1) { | ||
| 237 | uintptr_t address; | ||
| 238 | p = malloc(32); | ||
| 239 | address = (uintptr_t)(void *)p; | ||
| 240 | /* we don't want to have a chunk on the last slot of a page */ | ||
| 241 | if (address / getpagesize() == (address + 32) / getpagesize()) | ||
| 242 | break; | ||
| 243 | free(p); | ||
| 244 | } | ||
| 235 | p[32] = 0; | 245 | p[32] = 0; |
| 236 | for (i = 0; i < 10000; i++) | 246 | for (i = 0; i < 10000; i++) |
| 237 | p = malloc(32); | 247 | p = malloc(32); |
