Re: [hackers] [sbase] ed: Use reallocarray || Michael Forney
Hi,
On Tue, Dec 31, 2019 at 10:47:28PM +0100, git_AT_suckless.org wrote:
> diff --git a/ed.c b/ed.c
> index b844e86..e998e81 100644
> --- a/ed.c
> +++ b/ed.c
> _AT_@ -204,7 +204,7 @@ makeline(char *s, int *off)
> if (lastidx >= idxsize) {
> lp = NULL;
> if (idxsize <= SIZE_MAX - NUMLINES)
> - lp = realloc(zero, (idxsize + NUMLINES) * sizeof(*lp));
> + lp = reallocarray(zero, idxsize + NUMLINES, sizeof(*lp));
reallocarray is not a posix function, so it shouldn't be used here. If you
don't fell confortable using realloc due to the possibility of overflow then
you should add an explicit check against it.
Regards,
Received on Thu Jan 02 2020 - 09:28:40 CET
This archive was generated by hypermail 2.3.0
: Thu Jan 02 2020 - 09:36:24 CET