aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-02-24 18:03:50 -0800
committerGuy Harris <guy@alum.mit.edu>2016-02-25 02:04:17 +0000
commit6257b65481112d584bcd55de3945c8601a1c5160 (patch)
treeb87a35de0471c8ce29b3169ec14b62ad52e9f0b8 /wiretap
parent40fe88daf42f5018507ab437b0dfd9191fa28443 (diff)
Fix allocation of option bocks in pcapng_read().
We don't need to allocate an WTAP_OPTION_BLOCK_IF_DESCR option block; don't use the value we allocated. We must not allocate an WTAP_OPTION_BLOCK_IF_STATS option block until we need it, as we may have to allocate *more than one* of them here! The old code would reuse the same block, adding it more than once, causing a "freeing already freed data"/"freeing non-allocated data" error on some platforms. Change-Id: I8582627c1f5deecfd4f6490dcdf8c31ee3809d12 Reviewed-on: https://code.wireshark.org/review/14130 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/pcapng.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c
index 879f349de4..f9042d3d7e 100644
--- a/wiretap/pcapng.c
+++ b/wiretap/pcapng.c
@@ -2560,8 +2560,8 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
{
pcapng_t *pcapng = (pcapng_t *)wth->priv;
wtapng_block_t wblock;
- wtap_optionblock_t wtapng_if_descr = wtap_optionblock_create(WTAP_OPTION_BLOCK_IF_DESCR);
- wtap_optionblock_t if_stats = wtap_optionblock_create(WTAP_OPTION_BLOCK_IF_STATS);
+ wtap_optionblock_t wtapng_if_descr;
+ wtap_optionblock_t if_stats;
wtapng_if_stats_mandatory_t *if_stats_mand_block, *if_stats_mand;
wtapng_if_descr_mandatory_t *wtapng_if_descr_mand;
@@ -2626,6 +2626,7 @@ pcapng_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
wtapng_if_descr_mand->interface_statistics = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
}
+ if_stats = wtap_optionblock_create(WTAP_OPTION_BLOCK_IF_STATS);
if_stats_mand = (wtapng_if_stats_mandatory_t*)wtap_optionblock_get_mandatory_data(if_stats);
if_stats_mand->interface_id = if_stats_mand_block->interface_id;
if_stats_mand->ts_high = if_stats_mand_block->ts_high;