summaryrefslogtreecommitdiff
path: root/src/regress/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/regress/lib')
-rw-r--r--src/regress/lib/libc/malloc/malloc_errs/malloc_errs.c27
1 files changed, 21 insertions, 6 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 e0efb6ebf3..6040590a65 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.2 2023/05/09 19:07:37 otto Exp $ */ 1/* $OpenBSD: malloc_errs.c,v 1.3 2023/06/04 06:58:33 otto Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Otto Moerbeek <otto@drijf.net> 3 * Copyright (c) 2023 Otto Moerbeek <otto@drijf.net>
4 * 4 *
@@ -138,9 +138,7 @@ t8(void)
138void 138void
139t9(void) 139t9(void)
140{ 140{
141 char *p; 141 char *p = malloc(100);
142
143 p = malloc(100);
144 p[100] = 0; 142 p[100] = 0;
145 free(p); 143 free(p);
146} 144}
@@ -191,7 +189,6 @@ t15(void)
191void 189void
192t16(void) 190t16(void)
193{ 191{
194 abort(); /* not yet */
195 char *p = recallocarray(NULL, 0, 16, 1); 192 char *p = recallocarray(NULL, 0, 16, 1);
196 char *q = recallocarray(p, 2, 3, 16); 193 char *q = recallocarray(p, 2, 3, 16);
197} 194}
@@ -208,11 +205,27 @@ t17(void)
208void 205void
209t18(void) 206t18(void)
210{ 207{
211 abort(); /* not yet */
212 char *p = recallocarray(NULL, 0, 1, getpagesize()); 208 char *p = recallocarray(NULL, 0, 1, getpagesize());
213 char *q = recallocarray(p, 2, 3, getpagesize()); 209 char *q = recallocarray(p, 2, 3, getpagesize());
214} 210}
215 211
212/* recallocarray with wrong size, pages */
213void
214t19(void)
215{
216 char *p = recallocarray(NULL, 0, 1, 10 * getpagesize());
217 char *q = recallocarray(p, 1, 2, 4 * getpagesize());
218}
219
220/* canary check pages */
221void
222t20(void)
223{
224 char *p = malloc(2*getpagesize() - 100);
225 p[2*getpagesize() - 100] = 0;
226 free(p);
227}
228
216struct test { 229struct test {
217 void (*test)(void); 230 void (*test)(void);
218 const char *flags; 231 const char *flags;
@@ -238,6 +251,8 @@ struct test tests[] = {
238 { t16, "" }, 251 { t16, "" },
239 { t17, "C" }, 252 { t17, "C" },
240 { t18, "" }, 253 { t18, "" },
254 { t19, "" },
255 { t20, "C" },
241}; 256};
242 257
243int main(int argc, char *argv[]) 258int main(int argc, char *argv[])