use a cleanup handler for robustness.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21950
dc483132-0cff-0310-8789-
dd5450dbe970
if (new_node == NULL)
return ENOMEM;
err = krb5_copy_creds(ctx, creds, &new_node->creds);
- if (err) {
- free(new_node);
- return err;
- }
+ if (err)
+ goto cleanup;
err = k5_cc_mutex_lock(ctx, &mptr->lock);
if (err)
- return err;
+ goto cleanup;
new_node->next = mptr->link;
mptr->link = new_node;
update_mcc_change_time(mptr);
k5_cc_mutex_unlock(ctx, &mptr->lock);
return 0;
+cleanup:
+ free(new_node);
+ return err;
}
static krb5_error_code KRB5_CALLCONV