change_password resource cleanup?
Joonas Tuomisto <[email protected]> Sat, 28 Jun 2025 07:50:54 +0300
| Newsgroups | gmane.comp.encryption.kerberos.devel |
|---|---|
| Message-ID | <CALuYaDz3-DjXTqsN+yz+PDKoALq0nzETcxmnLBEw6cN4L5zgCQ@mail.gmail.com> |
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! _______________________________________________ krbdev mailing list [email protected] https://mailman.mit.edu/mailman/listinfo/krbdev