pam_ksu: Move the realm free to end of function

This avoids a use after free.

Noted by:	jhb
This commit is contained in:
Cy Schubert 2025-06-16 11:40:51 -07:00
parent 45165aab2d
commit 98f18cd988

View file

@ -85,8 +85,6 @@ krb5_make_principal(krb5_context context, krb5_principal principal,
if ((rc = krb5_get_default_realm(context, &temp_realm)))
return (rc);
realm=temp_realm;
if (temp_realm)
free(temp_realm);
}
va_start(ap, realm);
/*
@ -99,6 +97,8 @@ krb5_make_principal(krb5_context context, krb5_principal principal,
*/
rc = krb5_build_principal_va(context, principal, strlen(realm), realm, ap);
va_end(ap);
if (temp_realm)
free(temp_realm);
return (rc);
}
#endif