From 0cfdb7b871fd04c7a500001d2d0961779adf0ed5 Mon Sep 17 00:00:00 2001 From: Tom Carroll Date: Sun, 16 May 2021 22:58:24 -0700 Subject: [PATCH] Use C99 initializer instead of memset. Strictly speaking, using memset() here violates strict aliasing rules, and it would be entirely permissible for an assert() like this example to *fail*: struct gtls_cert_info gci; memset(&gci, 0, sizeof gci); assert(gci.pkey == NULL); Signed-off-by: Tom Carroll --- gnutls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnutls.c b/gnutls.c index 9b08047f..8420ef4e 100644 --- a/gnutls.c +++ b/gnutls.c @@ -942,7 +942,7 @@ static void free_gtls_cert_info(struct gtls_cert_info *gci) for (unsigned int i = 0; i < gci->nr_certs; i++) gnutls_x509_crt_deinit(gci->certs[i]); gnutls_free(gci->certs); - memset(gci, 0, sizeof(*gci)); + *gci = (struct gtls_cert_info) {0}; } static int import_cert(gnutls_x509_crt_t *cert, const gnutls_datum_t *der) -- 2.49.0