From e0273bc4d14db73824b0f1fcfcba5c26c2ae2e21 Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Mon, 25 Jul 2011 15:54:39 +0000 Subject: [PATCH] Never return profile on error opening file If profile_open_file() discovers a shared tree for the file, but encounters an error when updating it, dereference the data and return a null profile rather than returning an error and a newly broken file object. Otherwise we'd leak the returned file object in profile_init(). git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25047 dc483132-0cff-0310-8789-dd5450dbe970 --- src/util/profile/prof_file.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/util/profile/prof_file.c b/src/util/profile/prof_file.c index 988afacec..b0bb087eb 100644 --- a/src/util/profile/prof_file.c +++ b/src/util/profile/prof_file.c @@ -258,10 +258,15 @@ errcode_t profile_open_file(const_profile_filespec_t filespec, (void) k5_mutex_unlock(&g_shared_trees_mutex); retval = profile_update_file_data(data, NULL); free(expanded_filename); + if (retval) { + profile_dereference_data(data); + free(prf); + return retval; + } prf->data = data; *ret_prof = prf; scan_shared_trees_unlocked(); - return retval; + return 0; } (void) k5_mutex_unlock(&g_shared_trees_mutex); data = profile_make_prf_data(expanded_filename); -- 2.26.2