hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 3959419099c86531a7419908d23088235762744e
parent 6fc89deae9d37f6c3fff1000e41adbf8eb50cca3
Author: Lorenz (xha) <me@xha.li>
Date:   Sun, 15 Dec 2024 12:13:54 +0100

malloc+libc: ensure that malloc(0) returns null

on openbsd, for example, malloc(0) will return a pointer. we don't
want this.

Signed-off-by: Lorenz (xha) <me@xha.li>

Diffstat:
Mrt/malloc+libc.ha | 1+
1 file changed, 1 insertion(+), 0 deletions(-)

diff --git a/rt/malloc+libc.ha b/rt/malloc+libc.ha @@ -4,6 +4,7 @@ // Allocates n bytes of memory and returns a pointer to them, or null if there // is insufficient memory. export fn malloc(n: size) nullable *opaque = { + if (n == 0) return null; return c_malloc(n); };