aboutsummaryrefslogtreecommitdiffstats
path: root/caputils
diff options
context:
space:
mode:
authorMikael Kanstrup <mikael.kanstrup@gmail.com>2017-08-25 14:05:42 +0200
committerGuy Harris <guy@alum.mit.edu>2017-08-25 19:41:34 +0000
commitb1a041898333a8d38387dca4fa6d509881845072 (patch)
tree3eb0abd246fae05d218e7e4a3e06fb6f875814a4 /caputils
parent9ae80aea082384605e647f55fbc4d2910811a929 (diff)
Fix leaked timestamp records
Valgrind reports leaked timestamp records. A comment stated that the timestamp info members only contain static data. That claim was only true for some cases, not all so make all cases allocate memory and have them properly freed when removed. Fixes: aca55a2 ("Add hardware timestamping support") Change-Id: I31e4689070019ad1f531008394e7d6e48318c70c Reviewed-on: https://code.wireshark.org/review/23206 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'caputils')
-rw-r--r--caputils/capture-pcap-util.c11
-rw-r--r--caputils/capture_ifinfo.h4
2 files changed, 8 insertions, 7 deletions
diff --git a/caputils/capture-pcap-util.c b/caputils/capture-pcap-util.c
index 07d7db06f7..910918c28d 100644
--- a/caputils/capture-pcap-util.c
+++ b/caputils/capture-pcap-util.c
@@ -671,9 +671,10 @@ free_linktype_cb(gpointer data, gpointer user_data _U_)
static void
free_timestamp_cb(gpointer data, gpointer user_data _U_)
{
- /* timestamp_info_t's contents are immutable and in static memory,
- * so we only need to free the struct itself
- */
+ timestamp_info_t *timestamp_info = (timestamp_info_t *)data;
+
+ g_free(timestamp_info->name);
+ g_free(timestamp_info->description);
g_free(data);
}
@@ -987,8 +988,8 @@ get_pcap_timestamp_types(pcap_t *pch _U_, char **err_str _U_)
while (ntypes--) {
timestamp_info_t *info = (timestamp_info_t *)g_malloc(sizeof *info);
- info->name = pcap_tstamp_type_val_to_name(types[ntypes]);
- info->description = pcap_tstamp_type_val_to_description(types[ntypes]);
+ info->name = g_strdup(pcap_tstamp_type_val_to_name(types[ntypes]));
+ info->description = g_strdup(pcap_tstamp_type_val_to_description(types[ntypes]));
list = g_list_prepend(list, info);
}
diff --git a/caputils/capture_ifinfo.h b/caputils/capture_ifinfo.h
index 48c54feec8..65084b8d60 100644
--- a/caputils/capture_ifinfo.h
+++ b/caputils/capture_ifinfo.h
@@ -115,8 +115,8 @@ typedef struct {
* Information about timestamp types.
*/
typedef struct {
- const char *name; /* e.g. "adapter_unsynced" */
- const char *description; /* description from libpcap e.g. "Adapter, not synced with system time" */
+ char *name; /* e.g. "adapter_unsynced" */
+ char *description; /* description from libpcap e.g. "Adapter, not synced with system time" */
} timestamp_info_t;
/**