krb5 commit: Fix memory leak parsing name with default realm

Greg Hudson ghudson at MIT.EDU
Tue Aug 7 01:00:44 EDT 2012


https://github.com/krb5/krb5/commit/7abd3407cae8a68fc78884037c46405bb2fb91ec
commit 7abd3407cae8a68fc78884037c46405bb2fb91ec
Author: Greg Hudson <ghudson at mit.edu>
Date:   Tue Aug 7 00:54:46 2012 -0400

    Fix memory leak parsing name with default realm
    
    After 74beb75bb07e3921d10c8eec05eacb1f393e5e44, allocate_princ()
    allocates a one-byte realm field even if the principal doesn't have
    one, so if we're replacing it with the default realm, we need to free
    that.

 src/lib/krb5/krb/parse.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/lib/krb5/krb/parse.c b/src/lib/krb5/krb/parse.c
index c55381a..a696c71 100644
--- a/src/lib/krb5/krb/parse.c
+++ b/src/lib/krb5/krb/parse.c
@@ -208,6 +208,7 @@ krb5_parse_name_flags(krb5_context context, const char *name,
             ret = krb5_get_default_realm(context, &default_realm);
             if (ret)
                 goto cleanup;
+            krb5_free_data_contents(context, &princ->realm);
             princ->realm = string2data(default_realm);
         }
     } else if (no_realm) {


More information about the cvs-krb5 mailing list