zero_realloc_abort.c 488 B

123456789101112131415161718192021222324252627
  1. #include "test/jemalloc_test.h"
  2. #include <signal.h>
  3. static bool abort_called = false;
  4. void set_abort_called() {
  5. abort_called = true;
  6. };
  7. TEST_BEGIN(test_realloc_abort) {
  8. abort_called = false;
  9. safety_check_set_abort(&set_abort_called);
  10. void *ptr = mallocx(42, 0);
  11. expect_ptr_not_null(ptr, "Unexpected mallocx error");
  12. ptr = realloc(ptr, 0);
  13. expect_true(abort_called, "Realloc with zero size didn't abort");
  14. }
  15. TEST_END
  16. int
  17. main(void) {
  18. return test(
  19. test_realloc_abort);
  20. }