Don't depend on behavior of malloc(0)
authorJohn Carr <jfc@mit.edu>
Fri, 21 Aug 1992 02:53:29 +0000 (02:53 +0000)
committerJohn Carr <jfc@mit.edu>
Fri, 21 Aug 1992 02:53:29 +0000 (02:53 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2345 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/krb/copy_tick.c

index 0178a04d9e0522a6128aaf5c4c22d6f7a3559505..bdb950d44db04e4c58e0ae0a104a71fe8df0b64d 100644 (file)
@@ -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);