From 06351413b72f8b6e5092e0cef0beb9dfea358855 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Thu, 2 Jul 2026 16:30:47 +0200 Subject: [PATCH] Allocate minimum 1 byte in malloc_nofail when size is 0 to prevent process abort --- cmdline/support.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmdline/support.c b/cmdline/support.c index 0476805f..0715de56 100644 --- a/cmdline/support.c +++ b/cmdline/support.c @@ -2142,7 +2142,7 @@ void malloc_fail(size_t size) void* malloc_nofail(size_t size) { - void* ptr = malloc(size); + void* ptr = malloc(size ? size : 1); if (!ptr) { /* LCOV_EXCL_START */ @@ -2175,7 +2175,7 @@ void* calloc_nofail(size_t count, size_t size) size *= count; /* see the note in malloc_nofail() of why we don't use calloc() */ - ptr = malloc(size); + ptr = malloc(size ? size : 1); if (!ptr) { /* LCOV_EXCL_START */