From ac53ce5c99be14edf48d1ef3e5460295cd649b2f Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sun, 16 Jan 2022 23:02:38 -0500 Subject: [PATCH] lib/gssapi/spnego: _gss_negoex_init do not leak error message Change-Id: I870ed0bd8de7bc6ab5b8cf7c6d3816d04de354fa --- lib/gssapi/spnego/negoex_ctx.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/gssapi/spnego/negoex_ctx.c b/lib/gssapi/spnego/negoex_ctx.c index 13e28bb59..fd337eee2 100644 --- a/lib/gssapi/spnego/negoex_ctx.c +++ b/lib/gssapi/spnego/negoex_ctx.c @@ -904,12 +904,14 @@ cleanup: if (GSS_ERROR(major)) { if (!mech_error) { - krb5_context context = _gss_mg_krb5_context(); - - gss_mg_set_error_string(GSS_SPNEGO_MECHANISM, - major, *minor, - "NegoEx failed to initialize security context: %s", - krb5_get_error_message(context, *minor)); + krb5_context context = _gss_mg_krb5_context(); + char *emsg = krb5_get_error_message(context, *minor); + + gss_mg_set_error_string(GSS_SPNEGO_MECHANISM, + major, *minor, + "NegoEx failed to initialize security context: %s", + emsg); + krb5_free_error_message(context, emsg); } _gss_negoex_release_context(ctx); -- 2.11.4.GIT