From 269a9a8ecfad6479fa9448c29984ec4b36d4563c Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Mon, 24 Jul 2023 02:28:09 -0400 Subject: [PATCH] fix!: use `abort` instead of `exit(1)` when allocations fail --- lib/src/alloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/alloc.c b/lib/src/alloc.c index a5d86fcd..30597571 100644 --- a/lib/src/alloc.c +++ b/lib/src/alloc.c @@ -5,7 +5,7 @@ static void *ts_malloc_default(size_t size) { void *result = malloc(size); if (size > 0 && !result) { fprintf(stderr, "tree-sitter failed to allocate %zu bytes", size); - exit(1); + abort(); } return result; } @@ -14,7 +14,7 @@ static void *ts_calloc_default(size_t count, size_t size) { void *result = calloc(count, size); if (count > 0 && !result) { fprintf(stderr, "tree-sitter failed to allocate %zu bytes", count * size); - exit(1); + abort(); } return result; } @@ -23,7 +23,7 @@ static void *ts_realloc_default(void *buffer, size_t size) { void *result = realloc(buffer, size); if (size > 0 && !result) { fprintf(stderr, "tree-sitter failed to reallocate %zu bytes", size); - exit(1); + abort(); } return result; }