From 012a179785abada629fa324652755c6acb51be74 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Tue, 21 Feb 2017 09:57:16 -0800 Subject: Fix a double free. In create_persconffile_profile, pf_dir_path_copy needs to be allocated separately since the subsequent call to get_dirname is destructive. Add back a call to g_strdup. This should hopefully fix a crash in the Win32 buildbot. Change-Id: I591b5845032c9b8a5324bf6ac60fc43d1e92ac2e Reviewed-on: https://code.wireshark.org/review/20231 Reviewed-by: Gerald Combs Petri-Dish: Gerald Combs Reviewed-by: Guy Harris --- wsutil/filesystem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'wsutil/filesystem.c') diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c index f982435427..1f9997eaff 100644 --- a/wsutil/filesystem.c +++ b/wsutil/filesystem.c @@ -1609,7 +1609,7 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return) * doing a "stat()" on it. If it's a drive letter, * or if the "stat()" succeeds, we assume it exists. */ - pf_dir_path_copy = pf_dir_path; + pf_dir_path_copy = g_strdup(pf_dir_path); pf_dir_parent_path = get_dirname(pf_dir_path_copy); pf_dir_parent_path_len = strlen(pf_dir_parent_path); if (pf_dir_parent_path_len > 0 @@ -1623,6 +1623,7 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return) save_errno = errno; *pf_dir_path_return = pf_dir_path; errno = save_errno; + g_free(pf_dir_path_copy); return -1; } /* @@ -1631,6 +1632,7 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return) ret = ws_mkdir(pf_dir_parent_path, 0755); if (ret == -1) { *pf_dir_path_return = pf_dir_parent_path; + g_free(pf_dir_path); return -1; } } -- cgit v1.2.1