diff options
author | svn2git <svn2git@FreeBSD.org> | 1994-07-01 08:00:00 +0000 |
---|---|---|
committer | svn2git <svn2git@FreeBSD.org> | 1994-07-01 08:00:00 +0000 |
commit | 5e0e9b99dc3fc0ecd49d929db0d57c784b66f481 (patch) | |
tree | e779b5a6edddbb949b7990751b12d6f25304ba86 /lib/libmalloc/tests/t5.c | |
parent | a16f65c7d117419bd266c28a1901ef129a337569 (diff) |
Diffstat (limited to 'lib/libmalloc/tests/t5.c')
-rw-r--r-- | lib/libmalloc/tests/t5.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/libmalloc/tests/t5.c b/lib/libmalloc/tests/t5.c new file mode 100644 index 000000000000..f25df6045594 --- /dev/null +++ b/lib/libmalloc/tests/t5.c @@ -0,0 +1,31 @@ +/* + * posted to the net by someone who asked "Why is this causing malloc to + * dump core! Modified slightly to free the pointers, which causes my + * debugging malloc to find the bug. Turning on malloc_debug(2) also + * spots the problem. + */ +#include <stdio.h> + +int +main() +{ + char *p[3], wd[128]; + int len, i; + char *malloc(); + int strlen(); + + strcpy(wd,"test"); + + for (i=0; i<3; i++) { + len = strlen(wd); + if ((p[i] = malloc(len)) == NULL) { + printf("ERROR: malloc failed\n"); + exit(-1); + } + else + strcpy(p[i],wd); + } + for(i=0; i < 3; i++) + free(p[i]); + return 0; +} |