Blame malloc/tst-tcfree1.c
|
Packit Service |
3b71a4 |
/* Test that malloc tcache catches double free.
|
|
Packit Service |
3b71a4 |
Copyright (C) 2018 Free Software Foundation, Inc.
|
|
Packit Service |
3b71a4 |
This file is part of the GNU C Library.
|
|
Packit Service |
3b71a4 |
|
|
Packit Service |
3b71a4 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
3b71a4 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
3b71a4 |
License as published by the Free Software Foundation; either
|
|
Packit Service |
3b71a4 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
3b71a4 |
|
|
Packit Service |
3b71a4 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
3b71a4 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
3b71a4 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
3b71a4 |
Lesser General Public License for more details.
|
|
Packit Service |
3b71a4 |
|
|
Packit Service |
3b71a4 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
3b71a4 |
License along with the GNU C Library; if not, see
|
|
Packit Service |
3b71a4 |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
3b71a4 |
|
|
Packit Service |
3b71a4 |
#include <errno.h>
|
|
Packit Service |
3b71a4 |
#include <error.h>
|
|
Packit Service |
3b71a4 |
#include <limits.h>
|
|
Packit Service |
3b71a4 |
#include <malloc.h>
|
|
Packit Service |
3b71a4 |
#include <stdlib.h>
|
|
Packit Service |
3b71a4 |
#include <stdio.h>
|
|
Packit Service |
3b71a4 |
#include <sys/signal.h>
|
|
Packit Service |
3b71a4 |
|
|
Packit Service |
3b71a4 |
static int
|
|
Packit Service |
3b71a4 |
do_test (void)
|
|
Packit Service |
3b71a4 |
{
|
|
Packit Service |
3b71a4 |
/* Do one allocation of any size that fits in tcache. */
|
|
Packit Service |
3b71a4 |
char * volatile x = malloc (32);
|
|
Packit Service |
3b71a4 |
|
|
Packit Service |
3b71a4 |
free (x); // puts in tcache
|
|
Packit Service |
3b71a4 |
free (x); // should abort
|
|
Packit Service |
3b71a4 |
|
|
Packit Service |
3b71a4 |
printf("FAIL: tcache double free not detected\n");
|
|
Packit Service |
3b71a4 |
return 1;
|
|
Packit Service |
3b71a4 |
}
|
|
Packit Service |
3b71a4 |
|
|
Packit Service |
3b71a4 |
#define TEST_FUNCTION do_test
|
|
Packit Service |
3b71a4 |
#define EXPECTED_SIGNAL SIGABRT
|
|
Packit Service |
3b71a4 |
#include <support/test-driver.c>
|