summaryrefslogtreecommitdiff
path: root/libcacard/cac.c
diff options
context:
space:
mode:
authorMichael Tokarev <mjt@tls.msk.ru>2014-05-08 19:51:01 +0400
committerMichael Tokarev <mjt@tls.msk.ru>2014-05-24 00:07:29 +0400
commit78a4b8d2051bff8e8794e9419b7925122212b096 (patch)
tree687653b7bb47b09b472676db67d50acea37e2cfb /libcacard/cac.c
parent6054d883d6138bfc92c73a7c090c824b64086fd2 (diff)
libcacard: g_malloc cleanups
This patch replaces g_malloc() in libcacard into g_new() or g_new0() where appropriate (removing some init-to-zero surrounding code), g_malloc+memcpy into g_memdup() and the like. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Alon Levy <alevy@redhat.com>
Diffstat (limited to 'libcacard/cac.c')
-rw-r--r--libcacard/cac.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/libcacard/cac.c b/libcacard/cac.c
index 74ef3e3cec..122129ec14 100644
--- a/libcacard/cac.c
+++ b/libcacard/cac.c
@@ -310,16 +310,11 @@ static VCardAppletPrivate *
cac_new_pki_applet_private(const unsigned char *cert,
int cert_len, VCardKey *key)
{
- CACPKIAppletData *pki_applet_data = NULL;
- VCardAppletPrivate *applet_private = NULL;
- applet_private = (VCardAppletPrivate *)g_malloc(sizeof(VCardAppletPrivate));
+ CACPKIAppletData *pki_applet_data;
+ VCardAppletPrivate *applet_private;
+ applet_private = g_new0(VCardAppletPrivate, 1);
pki_applet_data = &(applet_private->u.pki_data);
- pki_applet_data->cert_buffer = NULL;
- pki_applet_data->cert_buffer_len = 0;
- pki_applet_data->sign_buffer = NULL;
- pki_applet_data->sign_buffer_len = 0;
- pki_applet_data->key = NULL;
pki_applet_data->cert = (unsigned char *)g_malloc(cert_len+1);
/*
* if we want to support compression, then we simply change the 0 to a 1