malloc(0) returns non-NULL. [krb5-admin/46]
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9142
dc483132-0cff-0310-8789-
dd5450dbe970
+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
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;
}