Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Sep 2019 11:56:41 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Toomas Soome <tsoome@FreeBSD.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r352421 - head/stand/libsa
Message-ID:  <20190917085641.GY2559@kib.kiev.ua>
In-Reply-To: <201909162028.x8GKS9jK064079@repo.freebsd.org>
References:  <201909162028.x8GKS9jK064079@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Sep 16, 2019 at 08:28:09PM +0000, Toomas Soome wrote:
> Author: tsoome
> Date: Mon Sep 16 20:28:08 2019
> New Revision: 352421
> URL: https://svnweb.freebsd.org/changeset/base/352421
> 
> Log:
>   loader: Malloc(0) should return NULL.
>   
>   We really should not allocate anything with size 0.
Why ?  This is quite unexpected from other environments, where
malloc(0) returns unique object.

> 
> Modified:
>   head/stand/libsa/zalloc_malloc.c
> 
> Modified: head/stand/libsa/zalloc_malloc.c
> ==============================================================================
> --- head/stand/libsa/zalloc_malloc.c	Mon Sep 16 20:26:53 2019	(r352420)
> +++ head/stand/libsa/zalloc_malloc.c	Mon Sep 16 20:28:08 2019	(r352421)
> @@ -55,6 +55,9 @@ Malloc(size_t bytes, const char *file, int line)
>  {
>      Guard *res;
>  
> +    if (bytes == 0)
> +	return (NULL);
> +
>  #ifdef USEENDGUARD
>      bytes += MALLOCALIGN + 1;
>  #else



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20190917085641.GY2559>