diff --git a/lib/krb5/cache.c b/lib/krb5/cache.c index 091dd97b4..c9f60900c 100644 --- a/lib/krb5/cache.c +++ b/lib/krb5/cache.c @@ -46,14 +46,11 @@ krb5_cc_register(krb5_context context, const krb5_cc_ops *ops, krb5_boolean override) { - char *prefix_copy; int i; for(i = 0; i < context->num_cc_ops && context->cc_ops[i].prefix; i++) { if(strcmp(context->cc_ops[i].prefix, ops->prefix) == 0) { - if(override) - free(context->cc_ops[i].prefix); - else { + if(!override) { krb5_set_error_string(context, "ccache type %s already exists", ops->prefix); @@ -61,18 +58,12 @@ krb5_cc_register(krb5_context context, } } } - prefix_copy = strdup(ops->prefix); - if (prefix_copy == NULL) { - krb5_set_error_string(context, "malloc: out of memory"); - return KRB5_CC_NOMEM; - } if(i == context->num_cc_ops) { krb5_cc_ops *o = realloc(context->cc_ops, (context->num_cc_ops + 1) * sizeof(*context->cc_ops)); if(o == NULL) { krb5_set_error_string(context, "malloc: out of memory"); - free(prefix_copy); return KRB5_CC_NOMEM; } context->num_cc_ops++; @@ -81,7 +72,6 @@ krb5_cc_register(krb5_context context, (context->num_cc_ops - i) * sizeof(*context->cc_ops)); } memcpy(&context->cc_ops[i], ops, sizeof(context->cc_ops[i])); - context->cc_ops[i].prefix = prefix_copy; return 0; }