From 0327078837bb5189c53080ef259d99e6c7075e6b Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 21 Feb 2017 17:41:55 -0800 Subject: Only do save_errno = errno and errno = save_errno around g_free(); There is *no* need to do it around an assignment statement. (We *probably* don't need to do it around g_free(), but better safe than sorry - maybe some memory allocator makes system calls to hand regions of the address space back.) Change-Id: Ib57540cc36b505aadf4a5e8885b9a744a35b1f75 Reviewed-on: https://code.wireshark.org/review/20236 Reviewed-by: Guy Harris --- wsutil/filesystem.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'wsutil') diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c index 1f9997eaff..33c78655d5 100644 --- a/wsutil/filesystem.c +++ b/wsutil/filesystem.c @@ -1549,10 +1549,10 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return) #ifdef _WIN32 char *pf_dir_path_copy, *pf_dir_parent_path; size_t pf_dir_parent_path_len; + int save_errno; #endif ws_statb64 s_buf; int ret; - int save_errno; if (profilename) { /* @@ -1570,9 +1570,7 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return) if (ws_stat64(pf_dir_path, &s_buf) != 0) { if (errno != ENOENT) { /* Some other problem; give up now. */ - save_errno = errno; *pf_dir_path_return = pf_dir_path; - errno = save_errno; return -1; } @@ -1592,9 +1590,7 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return) if (ws_stat64(pf_dir_path, &s_buf) != 0) { if (errno != ENOENT) { /* Some other problem; give up now. */ - save_errno = errno; *pf_dir_path_return = pf_dir_path; - errno = save_errno; return -1; } #ifdef _WIN32 @@ -1620,10 +1616,10 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return) */ if (errno != ENOENT) { /* Some other problem; give up now. */ - save_errno = errno; *pf_dir_path_return = pf_dir_path; - errno = save_errno; + save_errno = errno; g_free(pf_dir_path_copy); + errno = save_errno; return -1; } /* @@ -1632,7 +1628,9 @@ 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; + save_errno = errno; g_free(pf_dir_path); + errno = save_errno; return -1; } } -- cgit v1.2.3