summaryrefslogtreecommitdiff
path: root/test/unit/zero_realloc_abort.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/zero_realloc_abort.c')
-rw-r--r--test/unit/zero_realloc_abort.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/unit/zero_realloc_abort.c b/test/unit/zero_realloc_abort.c
new file mode 100644
index 000000000..a880d104b
--- /dev/null
+++ b/test/unit/zero_realloc_abort.c
@@ -0,0 +1,26 @@
+#include "test/jemalloc_test.h"
+
+#include <signal.h>
+
+static bool abort_called = false;
+
+void set_abort_called() {
+ abort_called = true;
+};
+
+TEST_BEGIN(test_realloc_abort) {
+ abort_called = false;
+ safety_check_set_abort(&set_abort_called);
+ void *ptr = mallocx(42, 0);
+ expect_ptr_not_null(ptr, "Unexpected mallocx error");
+ ptr = realloc(ptr, 0);
+ expect_true(abort_called, "Realloc with zero size didn't abort");
+}
+TEST_END
+
+int
+main(void) {
+ return test(
+ test_realloc_abort);
+}
+