summaryrefslogtreecommitdiff
path: root/wiretap
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-10-15 16:55:54 -0700
committerGuy Harris <guy@alum.mit.edu>2014-10-15 23:56:18 +0000
commit7bca9126edb97ac598007da4a6d5c187a7ea830e (patch)
treec8cb141916118644eaf8f3ae973f1181b2431334 /wiretap
parentf518089709feba05fe8acfab76be5afc8bd97021 (diff)
downloadwireshark-7bca9126edb97ac598007da4a6d5c187a7ea830e.tar.gz
Don't allocate the interfaces array until we've read the SHB.
Nothing from the SHB gets stored in the interfaces array - it's filled in from IDBs - so it doesn't need to exist when we read the first SHB, and thus doesn't need to be freed if the attempt to read the SHB gets an error or a "this isn't a pcap-ng file" indication. Update a comment while we're at it. Change-Id: Ie67edb52dcf13c974607e95e290661bf48be68ae Reviewed-on: https://code.wireshark.org/review/4711 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/pcapng.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c
index f997133feb..6660987a4c 100644
--- a/wiretap/pcapng.c
+++ b/wiretap/pcapng.c
@@ -2199,8 +2199,7 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
pn.if_fcslen = -1;
pn.version_major = -1;
pn.version_minor = -1;
- pn.interfaces = g_array_new(FALSE, FALSE, sizeof(interface_info_t));
-
+ pn.interfaces = NULL;
/* we don't expect any packet blocks yet */
wblock.frame_buffer = NULL;
@@ -2243,9 +2242,8 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
/*
* At this point, we've decided this is a pcap-NG file, not
- * some other type of file, so we can't return 0, as that
- * means "this isn't a pcap-NG file, try some other file
- * type".
+ * some other type of file, so we can't return WTAP_OPEN_NOT_MINE
+ * past this point.
*/
wth->shb_hdr.opt_comment = wblock.data.section.opt_comment;
wth->shb_hdr.shb_hardware = wblock.data.section.shb_hardware;
@@ -2258,6 +2256,7 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
pcapng = (pcapng_t *)g_malloc(sizeof(pcapng_t));
wth->priv = (void *)pcapng;
*pcapng = pn;
+ pcapng->interfaces = g_array_new(FALSE, FALSE, sizeof(interface_info_t));
wth->subtype_read = pcapng_read;
wth->subtype_seek_read = pcapng_seek_read;