common: Fix call to xtrycalloc
Neal H. Walfield
neal at walfield.org
Wed Sep 30 14:59:10 CEST 2015
Hi Niibe,
At Wed, 30 Sep 2015 20:04:51 +0900,
NIIBE Yutaka wrote:
> While grep'ing use cases of calloc, I found a simple error in
> strsplit. Even if it's not correct, it works well (allocation of
> memory can be larger, because of alignment requirement of element).
>
> Here's a correction.
>
> diff --git a/common/stringhelp.c b/common/stringhelp.c
> index 576c2ea..38c3832 100644
> --- a/common/stringhelp.c
> +++ b/common/stringhelp.c
> @@ -1230,7 +1230,7 @@ strsplit (char *string, char delim, char replacement, int *count)
> for (t = strchr (string, delim); t; t = strchr (t + 1, delim))
> fields ++;
>
> - result = xtrycalloc (sizeof (*result), (fields + 1));
> + result = xtrycalloc ((fields + 1), sizeof (*result));
> if (! result)
> return NULL;
Good catch. This looks reasonable, please check it in.
Neal
More information about the Gnupg-devel
mailing list