lib/krb5: gen_priv_key do not leak error string
hx509_get_error_string() returns an allocated string that must be freed with hx509_free_error_string(). Change-Id: Ib24713d2425f53eb69fc9ebfc7cc1af3272b6271
This commit is contained in:
@@ -446,10 +446,13 @@ gen_priv_key(krb5_context context,
|
||||
if (ret == 0)
|
||||
ret = _hx509_generate_private_key(context->hx509ctx, key_gen_ctx, key);
|
||||
_hx509_generate_private_key_free(&key_gen_ctx);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
const char *emsg = hx509_get_error_string(context->hx509ctx, ret);
|
||||
|
||||
krb5_set_error_message(context, ret,
|
||||
"Could not generate a private key: %s",
|
||||
hx509_get_error_string(context->hx509ctx, ret));
|
||||
"Could not generate a private key: %s", emsg);
|
||||
hx509_free_error_string(context->hx509ctx, emsg);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user