From 721aa6f74f17f56dd82873aefffb2d6683918b79 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Tue, 30 Nov 2021 10:55:34 +0000 Subject: Replace malloc+memset with calloc There are a number of places where we `malloc` some memory and then `memset` it to zero. Use `calloc` instead. Signed-off-by: Jeremy Sowden Signed-off-by: Pablo Neira Ayuso --- output/mysql/ulogd_output_MYSQL.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'output/mysql') diff --git a/output/mysql/ulogd_output_MYSQL.c b/output/mysql/ulogd_output_MYSQL.c index 643320c..66151fe 100644 --- a/output/mysql/ulogd_output_MYSQL.c +++ b/output/mysql/ulogd_output_MYSQL.c @@ -127,16 +127,12 @@ static int get_columns_mysql(struct ulogd_pluginstance *upi) upi->input.num_keys = mysql_num_fields(result); ulogd_log(ULOGD_DEBUG, "%u fields in table\n", upi->input.num_keys); - upi->input.keys = malloc(sizeof(struct ulogd_key) * - upi->input.num_keys); + upi->input.keys = calloc(upi->input.num_keys, sizeof(*upi->input.keys)); if (!upi->input.keys) { upi->input.num_keys = 0; ulogd_log(ULOGD_ERROR, "ENOMEM\n"); return -ENOMEM; } - - memset(upi->input.keys, 0, sizeof(struct ulogd_key) * - upi->input.num_keys); for (i = 0; (field = mysql_fetch_field(result)); i++) { char buf[ULOGD_MAX_KEYLEN+1]; -- cgit v1.2.3