aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/pcapng.c5
-rw-r--r--wiretap/wtap.c9
-rw-r--r--wiretap/wtap_opttypes.c11
3 files changed, 14 insertions, 11 deletions
diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c
index 55414e6e98..0d070c6b12 100644
--- a/wiretap/pcapng.c
+++ b/wiretap/pcapng.c
@@ -2487,6 +2487,7 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
case PCAPNG_BLOCK_NOT_SHB:
/* An error indicating that this isn't a pcap-ng file. */
wtap_optionblock_free(wblock.block);
+ wblock.block = NULL;
*err = 0;
*err_info = NULL;
return WTAP_OPEN_NOT_MINE;
@@ -2494,6 +2495,7 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
case PCAPNG_BLOCK_ERROR:
/* An I/O error, or this probably *is* a pcap-ng file but not a valid one. */
wtap_optionblock_free(wblock.block);
+ wblock.block = NULL;
return WTAP_OPEN_ERROR;
}
@@ -2506,6 +2508,7 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
*/
pcapng_debug("pcapng_open: first block type %u not SHB", wblock.type);
wtap_optionblock_free(wblock.block);
+ wblock.block = NULL;
return WTAP_OPEN_NOT_MINE;
}
pn.shb_read = TRUE;
@@ -2561,10 +2564,12 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
if (*err == 0) {
pcapng_debug("No more IDBs available...");
wtap_optionblock_free(wblock.block);
+ wblock.block = NULL;
break;
} else {
pcapng_debug("pcapng_open: couldn't read IDB");
wtap_optionblock_free(wblock.block);
+ wblock.block = NULL;
return WTAP_OPEN_ERROR;
}
}
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index cdb031ef7c..7ab03537ab 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -1180,10 +1180,8 @@ wtap_fdclose(wtap *wth)
void
wtap_close(wtap *wth)
{
- guint i, j;
+ guint i;
wtap_optionblock_t wtapng_if_descr;
- wtap_optionblock_t if_stats;
- wtapng_if_descr_mandatory_t* wtapng_if_descr_mand;
wtap_sequential_close(wth);
@@ -1205,11 +1203,6 @@ wtap_close(wtap *wth)
for(i = 0; i < wth->interface_data->len; i++) {
wtapng_if_descr = g_array_index(wth->interface_data, wtap_optionblock_t, i);
- wtapng_if_descr_mand = (wtapng_if_descr_mandatory_t*)wtap_optionblock_get_mandatory_data(wtapng_if_descr);
- for(j = 0; j < wtapng_if_descr_mand->num_stat_entries; j++) {
- if_stats = g_array_index(wtapng_if_descr_mand->interface_statistics, wtap_optionblock_t, j);
- wtap_optionblock_free(if_stats);
- }
wtap_optionblock_free(wtapng_if_descr);
}
g_array_free(wth->interface_data, TRUE);
diff --git a/wiretap/wtap_opttypes.c b/wiretap/wtap_opttypes.c
index 3486ef69a9..8a61297e26 100644
--- a/wiretap/wtap_opttypes.c
+++ b/wiretap/wtap_opttypes.c
@@ -155,16 +155,21 @@ static void wtap_optionblock_free_options(wtap_optionblock_t block)
void wtap_optionblock_free(wtap_optionblock_t block)
{
+ guint j;
+ wtap_optionblock_t if_stats;
+
if (block != NULL)
{
/* Need special consideration for freeing of the interface_statistics member */
if (block->type == WTAP_OPTION_BLOCK_IF_DESCR)
{
wtapng_if_descr_mandatory_t* mand = (wtapng_if_descr_mandatory_t*)block->mandatory_data;
- if (mand->num_stat_entries != 0)
- {
- g_array_free(mand->interface_statistics, TRUE);
+ for(j = 0; j < mand->num_stat_entries; j++) {
+ if_stats = g_array_index(mand->interface_statistics, wtap_optionblock_t, j);
+ wtap_optionblock_free(if_stats);
}
+
+ g_array_free(mand->interface_statistics, TRUE);
}
g_free(block->mandatory_data);