diff options
-rw-r--r-- | src/lib/krb4/ChangeLog | 6 | ||||
-rw-r--r-- | src/lib/krb4/g_cnffile.c | 6 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/lib/krb4/ChangeLog b/src/lib/krb4/ChangeLog index 6ae5f55..bd31edc 100644 --- a/src/lib/krb4/ChangeLog +++ b/src/lib/krb4/ChangeLog @@ -1,3 +1,9 @@ +2003-03-03 Tom Yu <tlyu@mit.edu> + + * g_cnffile.c (krb__get_srvtabname): Keep strdup()ed string in a + static variable and free it called again; this prevents a memory + leak. + 2003-02-28 Ezra Peisach <epeisach@bu.edu> * Makefile.in (clean-unix): Remove krb_err_txt.c on clean. Update diff --git a/src/lib/krb4/g_cnffile.c b/src/lib/krb4/g_cnffile.c index c31a9d2..8d61f50 100644 --- a/src/lib/krb4/g_cnffile.c +++ b/src/lib/krb4/g_cnffile.c @@ -56,7 +56,7 @@ krb__get_srvtabname(default_srvtabname) const char* names[3]; char **full_name = 0, **cpp; krb5_error_code retval; - char *retname; + static char *retname; if (!krb5__krb4_context) krb5_init_context(&krb5__krb4_context); @@ -67,6 +67,8 @@ krb__get_srvtabname(default_srvtabname) retval = profile_get_values(krb5__krb4_context->profile, names, &full_name); if (retval == 0 && full_name && full_name[0]) { + if (retname != NULL) + free(retname); retname = strdup(full_name[0]); for (cpp = full_name; *cpp; cpp++) krb5_xfree(*cpp); @@ -74,6 +76,8 @@ krb__get_srvtabname(default_srvtabname) return retname; } } + if (retname != NULL) + free(retname); retname = strdup(default_srvtabname); return retname; } |