krb5 commit: Fix memory leak in test KDB module

Greg Hudson <[email protected]>
Newsgroups gmane.comp.encryption.kerberos.cvs
Message-ID <[email protected]>
https://github.com/krb5/krb5/commit/d9719c9f4112c3d1881cdbd09c484312f70e16a7
commit d9719c9f4112c3d1881cdbd09c484312f70e16a7
Author: Greg Hudson <[email protected]>
Date:   Tue Mar 19 12:22:33 2019 -0400

    Fix memory leak in test KDB module
    
    test_get_s4u_x509_principal() needs to free canon before exiting.

 src/plugins/kdb/test/kdb_test.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/plugins/kdb/test/kdb_test.c b/src/plugins/kdb/test/kdb_test.c
index 8118e66..690c025 100644
--- a/src/plugins/kdb/test/kdb_test.c
+++ b/src/plugins/kdb/test/kdb_test.c
@@ -463,6 +463,7 @@ test_get_s4u_x509_principal(krb5_context context, const krb5_data *client_cert,
         krb5_principal_compare(context, princ, (*entry)->princ))
         return 0;
 
+    match = FALSE;
     check(krb5_unparse_name_flags(context, princ,
                                   KRB5_PRINCIPAL_UNPARSE_NO_REALM,
                                   &princ_name));
@@ -474,11 +475,10 @@ test_get_s4u_x509_principal(krb5_context context, const krb5_data *client_cert,
         check(krb5_parse_name(context, canon, &canon_princ));
         match = krb5_principal_compare(context, canon_princ, (*entry)->princ);
         krb5_free_principal(context, canon_princ);
-        if (match)
-            return 0;
     }
 
-    return KRB5KDC_ERR_CLIENT_NAME_MISMATCH;
+    free(canon);
+    return match ? 0 : KRB5KDC_ERR_CLIENT_NAME_MISMATCH;
 }
 
 static krb5_error_code
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.