change_password resource cleanup?
Joonas Tuomisto
jootuom at gmail.com
Sat Jun 28 00:50:54 EDT 2025
Hello,
I'm not really a C developer. As my first C "project", I'm working on
something using krb5_change_password(). Manual memory management is tricky!
Question:
krb5_change_password() returns the result_code_string and result_string
krb5_data structures. Are you supposed to free() them - or I suppose more
specifically, krb5_free_data() them after use?
The documentation for krb5_chpw_message() explicitly calls out that you
should krb5_free_string() its message_out. For krb5_change_password() it
does not.
Secondarily:
Are these krb5_free_* functions always safe to call or should you only
assume the structs exist (and require cleanup) when e.g.
krb5_change_password() returns with result_code set?
My code now has if (retval) ... if (result_code) ... sprinkled and I can
already see myself how you could easily end up with resource leaks with C
and different code paths. A common cleanup path helps.
Thanks!
More information about the krbdev
mailing list