[1749] in Kerberos-V5-bugs
memory leak...
daemon@ATHENA.MIT.EDU (Roland Schemers)
Wed Dec 20 02:59:09 1995
Date: Tue, 19 Dec 1995 23:55:46 -0800
From: Roland Schemers <schemers@Eng.Sun.COM>
To: krb5-bugs@MIT.EDU
Cc: warlord@Eng.Sun.COM
Hi. I found a memory leak in:
(120195 snapshot) src/lib/krb5/os/hst_realm.c:krb5_get_host_realm
Basically what happens is profile_get_string mallocs the value for &realm:
retval = profile_get_string(context->profile, "domain_realm", cp,
0, (char *)NULL, &realm);
But later on you have:
if (realm != (char *)NULL)
{
/* We found an exact match */
if (!(cp = (char *)malloc(strlen(realm)+1)))
return ENOMEM;
strcpy(cp, realm);
realm = cp; <----------- this nukes the malloc value of realm
}
Which blows away the malloc'd value for realm. I'm not sure how you want
to fix it, I think you can just say:
if (realm != (char*) NULL)
{
cp = realm;
}
But I haven't studied it close enough...
roland