summaryrefslogtreecommitdiff
path: root/ui/recent.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-10-04 11:31:19 +0200
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2015-10-04 15:45:02 +0000
commitc647faa8a90739963ba40a099a365197f90b2184 (patch)
tree779aa416faca634eb3eb5dcd84e8421a75720ce2 /ui/recent.c
parent49151eb28c421b61a89bd18feb509e9428909b1e (diff)
downloadwireshark-c647faa8a90739963ba40a099a365197f90b2184.tar.gz
Fix various memleaks
Found by starting Wireshark within an empty profile, opening Preferences, search for Protocol "IEEE 802.11" (because it has radio buttons), then close everything again. Many fixes are trivial, but the various recent_read_* functions in recent.c were changed to return a boolean such that the result can always be checked even if errno==0. QButtonGroup leak was hinted by Clang Static Analyzer, all other memleaks were found using ASAN/LSan. Change-Id: Ia73f5d4c09d92f22e72377be59e23342f8ad7211 Reviewed-on: https://code.wireshark.org/review/10776 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'ui/recent.c')
-rw-r--r--ui/recent.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/ui/recent.c b/ui/recent.c
index 2633ac92cf..82666ffff2 100644
--- a/ui/recent.c
+++ b/ui/recent.c
@@ -1208,7 +1208,7 @@ recent_set_arg(char *prefarg)
/* opens the user's recent common file and read the first part */
-void
+gboolean
recent_read_static(char **rf_path_return, int *rf_errno_return)
{
char *rf_path;
@@ -1241,8 +1241,6 @@ recent_read_static(char **rf_path_return, int *rf_errno_return)
read_prefs_file(rf_path, rf, read_set_recent_common_pair_static, NULL);
fclose(rf);
- g_free(rf_path);
- rf_path = NULL;
} else {
/* We failed to open it. If we failed for some reason other than
"it doesn't exist", return the errno and the pathname, so our
@@ -1250,14 +1248,17 @@ recent_read_static(char **rf_path_return, int *rf_errno_return)
if (errno != ENOENT) {
*rf_errno_return = errno;
*rf_path_return = rf_path;
+ return FALSE;
}
}
+ g_free(rf_path);
+ return TRUE;
}
/* opens the user's recent file and read the first part */
-void
+gboolean
recent_read_profile_static(char **rf_path_return, int *rf_errno_return)
{
char *rf_path, *rf_common_path;
@@ -1322,8 +1323,6 @@ recent_read_profile_static(char **rf_path_return, int *rf_errno_return)
fclose(rf);
}
g_free(rf_common_path);
- g_free(rf_path);
- rf_path = NULL;
} else {
/* We failed to open it. If we failed for some reason other than
"it doesn't exist", return the errno and the pathname, so our
@@ -1331,12 +1330,15 @@ recent_read_profile_static(char **rf_path_return, int *rf_errno_return)
if (errno != ENOENT) {
*rf_errno_return = errno;
*rf_path_return = rf_path;
+ return FALSE;
}
}
+ g_free(rf_path);
+ return TRUE;
}
/* opens the user's recent file and read it out */
-void
+gboolean
recent_read_dynamic(char **rf_path_return, int *rf_errno_return)
{
char *rf_path;
@@ -1361,8 +1363,6 @@ recent_read_dynamic(char **rf_path_return, int *rf_errno_return)
dfilter_combo_add_empty();
#endif
fclose(rf);
- g_free(rf_path);
- rf_path = NULL;
} else {
/* We failed to open it. If we failed for some reason other than
"it doesn't exist", return the errno and the pathname, so our
@@ -1370,8 +1370,11 @@ recent_read_dynamic(char **rf_path_return, int *rf_errno_return)
if (errno != ENOENT) {
*rf_errno_return = errno;
*rf_path_return = rf_path;
+ return FALSE;
}
}
+ g_free(rf_path);
+ return TRUE;
}
gint