* client_principal.c (kadm5_randkey_principal): Do not assume that
authorEzra Peisach <epeisach@mit.edu>
Fri, 4 Oct 1996 12:39:36 +0000 (12:39 +0000)
committerEzra Peisach <epeisach@mit.edu>
Fri, 4 Oct 1996 12:39:36 +0000 (12:39 +0000)
malloc(0) returns non-NULL. [krb5-admin/46]

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9142 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/kadm5/clnt/ChangeLog
src/lib/kadm5/clnt/client_principal.c

index 422c5220e2e451779e3ef2d22ef20a15c6df86e2..42b505efa334458094934267906ef0b8126e3d20 100644 (file)
@@ -1,3 +1,8 @@
+Fri Oct  4 08:38:16 1996  Ezra Peisach  <epeisach@kangaroo.mit.edu>
+
+       * client_principal.c (kadm5_randkey_principal): Do not assume that
+               malloc(0) returns non-NULL. [krb5-admin/46]
+
 Mon Aug 26 16:33:31 1996  Barry Jaspan  <bjaspan@mit.edu>
 
        * client_init.c (_kadm5_init_any): use DEFAULT_PROFILE_PATH
index c419227223055a1245e4677d76cbfb6d38495339..54ce1f30b08d8e0e72c5c571e18aa435c37dcd85 100644 (file)
@@ -278,21 +278,24 @@ kadm5_randkey_principal(void *server_handle,
         if (n_keys)
              *n_keys = r->n_keys;
         if (key) {
-             *key = (krb5_keyblock *) malloc(r->n_keys*sizeof(krb5_keyblock));
-             if (*key == NULL)
-                  return ENOMEM;
-             for (i = 0; i < r->n_keys; i++) {
-                  ret = krb5_copy_keyblock_contents(handle->context,
-                                                    &r->keys[i],
-                                                    &(*key)[i]);
-                  if (ret) {
-                       free(*key);
-                       return ENOMEM;
-                  }
-             }
-        }
+             if(r->n_keys) {
+                     *key = (krb5_keyblock *) 
+                             malloc(r->n_keys*sizeof(krb5_keyblock));
+                     if (*key == NULL)
+                             return ENOMEM;
+                     for (i = 0; i < r->n_keys; i++) {
+                             ret = krb5_copy_keyblock_contents(handle->context,
+                                                               &r->keys[i],
+                                                               &(*key)[i]);
+                             if (ret) {
+                                     free(*key);
+                                     return ENOMEM;
+                             }
+                     }
+             } else *key = NULL;
+         }
     }
-        
+
     return r->code;
 }