* which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2017 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2017, 2022 Russ Allbery <eagle@eyrie.org>
* Copyright 2006-2007, 2009-2014
* The Board of Trustees of the Leland Stanford Junior University
*
* process so that test programs that fork don't remove the ticket cache still
* used by the main program.
*/
-static void
-kerberos_free(void)
+void
+kerberos_free(struct kerberos_config *config_arg)
{
+ if (config_arg != config)
+ bail("invalid argument to kerberos_free");
test_tmpdir_free(tmpdir_ticket);
tmpdir_ticket = NULL;
if (config != NULL) {
free(config->password);
free(config->pkinit_principal);
free(config->pkinit_cert);
- free(config);
+
+ /*
+ * Free config_arg rather than config, since otherwise cppcheck thinks
+ * that config_arg could be const, which while technically true would
+ * look very weird since config_arg is invalidated by calling this
+ * function.
+ */
+ free(config_arg);
config = NULL;
}
if (krb5ccname != NULL) {
unlink(path);
free(path);
}
- kerberos_free();
+ kerberos_free(config);
}
if (primary)
kerberos_cleanup();
else
- kerberos_free();
+ kerberos_free(config);
}