From dfa2b7030c96525e591228cfbc27a94d3ad51df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Thu, 11 Dec 2008 05:05:21 +0000 Subject: [PATCH] use calloc and by that way avoid NULL de-ref, cid#31 git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24133 ec53bebd-3082-4978-b11e-865c3cabbd6b --- kcm/cache.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/kcm/cache.c b/kcm/cache.c index 96080689e..88b3ae25b 100644 --- a/kcm/cache.c +++ b/kcm/cache.c @@ -500,10 +500,9 @@ kcm_ccache_store_cred_internal(krb5_context context, for (c = &ccache->creds; *c != NULL; c = &(*c)->next) ; - *c = (struct kcm_creds *)malloc(sizeof(struct kcm_creds)); - if (*c == NULL) { + *c = (struct kcm_creds *)calloc(1, sizeof(**c)); + if (*c == NULL) return KRB5_CC_NOMEM; - } RAND_bytes((*c)->uuid, sizeof((*c)->uuid)); @@ -520,8 +519,6 @@ kcm_ccache_store_cred_internal(krb5_context context, ret = 0; } - (*c)->next = NULL; - return ret; }