xref: /netbsd-src/external/bsd/jemalloc/dist/test/unit/zero_realloc_abort.c (revision f8cf1a9151c7af1cb0bd8b09c13c66bca599c027)
1 #include "test/jemalloc_test.h"
2 
3 #include <signal.h>
4 
5 static bool abort_called = false;
6 
7 void set_abort_called() {
8 	abort_called = true;
9 };
10 
11 TEST_BEGIN(test_realloc_abort) {
12 	abort_called = false;
13 	safety_check_set_abort(&set_abort_called);
14 	void *ptr = mallocx(42, 0);
15 	expect_ptr_not_null(ptr, "Unexpected mallocx error");
16 	ptr = realloc(ptr, 0);
17 	expect_true(abort_called, "Realloc with zero size didn't abort");
18 }
19 TEST_END
20 
21 int
22 main(void) {
23 	return test(
24 	    test_realloc_abort);
25 }
26 
27