summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaan <daanl@outlook.com>2020-01-29 17:25:40 -0800
committerdaan <daanl@outlook.com>2020-01-29 17:25:40 -0800
commit7ff3ec2bf74b9014279103a55b632df182dacc7c (patch)
tree42377366bffe986fdd84fa050b0cb6a34d0f6633 /src
parent5d212d688f82a3b17f00faa11967e9459dc78715 (diff)
use EFAULT for buffer overflow and call abort in debug mode (as well as secure mode)
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c2
-rw-r--r--src/options.c8
2 files changed, 9 insertions, 1 deletions
diff --git a/src/alloc.c b/src/alloc.c
index e4324d7..6852d65 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -187,7 +187,7 @@ static void mi_check_padding(const mi_page_t* page, const mi_block_t* block) {
mi_block_t* const padding = (mi_block_t*)((uint8_t*)block + page->xblock_size - MI_PADDING);
mi_block_t* const decoded = mi_block_nextx(page, padding, page->key[0], page->key[1]);
if (decoded != block) {
- _mi_error_message(EINVAL, "buffer overflow in heap block %p: write after %zu bytes\n", block, page->xblock_size);
+ _mi_error_message(EFAULT, "buffer overflow in heap block %p: write after %zu bytes\n", block, page->xblock_size);
}
}
#else
diff --git a/src/options.c b/src/options.c
index af051aa..7559a4b 100644
--- a/src/options.c
+++ b/src/options.c
@@ -319,6 +319,14 @@ static volatile _Atomic(void*) mi_error_arg; // = NULL
static void mi_error_default(int err) {
UNUSED(err);
+#if (MI_DEBUG>0)
+ if (err==EFAULT) {
+ #ifdef _MSC_VER
+ __debugbreak();
+ #endif
+ abort();
+ }
+#endif
#if (MI_SECURE>0)
if (err==EFAULT) { // abort on serious errors in secure mode (corrupted meta-data)
abort();