From: John Carr Date: Fri, 21 Aug 1992 02:53:29 +0000 (+0000) Subject: Don't depend on behavior of malloc(0) X-Git-Tag: krb5-1.0-beta2~117 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=77cb1a4d7293e413d62b64f1840356b753dfa91c;p=krb5.git Don't depend on behavior of malloc(0) git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2345 dc483132-0cff-0310-8789-dd5450dbe970 --- 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);