From 77cb1a4d7293e413d62b64f1840356b753dfa91c Mon Sep 17 00:00:00 2001 From: John Carr Date: Fri, 21 Aug 1992 02:53:29 +0000 Subject: [PATCH] Don't depend on behavior of malloc(0) git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2345 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/krb/copy_tick.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/lib/krb5/krb/copy_tick.c b/src/lib/krb5/krb/copy_tick.c index 0178a04d9..bdb950d44 100644 --- a/src/lib/krb5/krb/copy_tick.c +++ b/src/lib/krb5/krb/copy_tick.c @@ -56,17 +56,22 @@ krb5_enc_tkt_part **partto; return retval; } tempto->transited = partfrom->transited; - tempto->transited.tr_contents.data = - malloc(partfrom->transited.tr_contents.length); - if (!tempto->transited.tr_contents.data) { - krb5_free_principal(tempto->client); - krb5_free_keyblock(tempto->session); - xfree(tempto); - return retval; + if (tempto->transited.tr_contents.length == 0) { + tempto->transited.tr_contents.data = 0; + } else { + tempto->transited.tr_contents.data = + malloc(partfrom->transited.tr_contents.length); + if (!tempto->transited.tr_contents.data) { + krb5_free_principal(tempto->client); + krb5_free_keyblock(tempto->session); + xfree(tempto); + return retval; + } + memcpy((char *)tempto->transited.tr_contents.data, + (char *)partfrom->transited.tr_contents.data, + partfrom->transited.tr_contents.length); } - memcpy((char *)tempto->transited.tr_contents.data, - (char *)partfrom->transited.tr_contents.data, - partfrom->transited.tr_contents.length); + if (retval = krb5_copy_addresses(partfrom->caddrs, &tempto->caddrs)) { xfree(tempto->transited.tr_contents.data); krb5_free_principal(tempto->client); -- 2.26.2