From 2ea3683347e3694dfaa7f8fb9725bec067e7fac1 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 18 Jan 2018 18:51:32 +0100 Subject: [PATCH] kex: Use calloc() instead of malloc() Signed-off-by: Andreas Schneider --- src/kex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kex.c b/src/kex.c index 911f644e..b658ed44 100644 --- a/src/kex.c +++ b/src/kex.c @@ -164,7 +164,7 @@ static char **tokenize(const char *chain){ ptr++; } /* now n contains the number of tokens, the first possibly empty if the list was empty too e.g. "" */ - tokens=malloc(sizeof(char *) * (n+1) ); /* +1 for the null */ + tokens = calloc(n + 1, sizeof(char *)); /* +1 for the null */ if (tokens == NULL) { SAFE_FREE(tmp); return NULL; @@ -208,7 +208,7 @@ char **ssh_space_tokenize(const char *chain){ ptr++; } /* now n contains the number of tokens, the first possibly empty if the list was empty too e.g. "" */ - tokens = malloc(sizeof(char *) * (n + 1)); /* +1 for the null */ + tokens = calloc(n + 1, sizeof(char *)); /* +1 for the null */ if (tokens == NULL) { SAFE_FREE(tmp); return NULL;