[pacman-dev] [PATCH] pacsort: safer sizeof types when allocating memory

Allan McRae allan at archlinux.org
Sat Jan 30 09:00:33 UTC 2016


On 30/01/16 00:47, Julien Ramseier wrote:
> ---
>  src/util/pacsort.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/src/util/pacsort.c b/src/util/pacsort.c
> index c69ae2f..a652b43 100644
> --- a/src/util/pacsort.c
> +++ b/src/util/pacsort.c
> @@ -80,7 +80,7 @@ static struct buffer_t *buffer_new(size_t initial_size)
>  		return NULL;
>  	}
>  
> -	buf->mem = calloc(initial_size, sizeof(char));
> +	buf->mem = calloc(initial_size, sizeof(*(buf->mem)));
>  	if(!buf->mem) {
>  		free(buf);
>  		return NULL;

Why is this safer?

A


More information about the pacman-dev mailing list