aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--wiretap/ascendtext.c1
-rw-r--r--wiretap/file_access.c8
-rw-r--r--wiretap/lanalyzer.c10
-rw-r--r--wiretap/libpcap.c9
-rw-r--r--wiretap/netmon.c5
-rw-r--r--wiretap/nettl.c7
-rw-r--r--wiretap/netxray.c1
7 files changed, 8 insertions, 33 deletions
diff --git a/wiretap/ascendtext.c b/wiretap/ascendtext.c
index bac0cccb0e..d0b4e765c6 100644
--- a/wiretap/ascendtext.c
+++ b/wiretap/ascendtext.c
@@ -225,7 +225,6 @@ int ascend_open(wtap *wth, int *err, gchar **err_info)
offset that we can apply to each packet.
*/
if (wtap_fstat(wth, &statbuf, err) == -1) {
- g_free(ascend);
return -1;
}
ascend->inittime = statbuf.st_ctime;
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index 8b9094498b..44528c1a6a 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -98,6 +98,14 @@
* If the routine handles this type of file, it should set the "file_type"
* field in the "struct wtap" to the type of the file.
*
+ * Note that the routine does not have to free the private data pointer on
+ * error. The caller takes care of that by calling wtap_close on error.
+ * (See https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8518)
+ *
+ * However, the caller does have to free the private data pointer when
+ * returning 0, since the next file type will be called and will likely
+ * just overwrite the pointer.
+ *
* Put the trace files that are merely saved telnet-sessions last, since it's
* possible that you could have captured someone a router telnet-session
* using another tool. So, a libpcap trace of an toshiba "snoop" session
diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c
index c3ed8f2efa..e8335c91ea 100644
--- a/wiretap/lanalyzer.c
+++ b/wiretap/lanalyzer.c
@@ -358,8 +358,6 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
*err = file_error(wth->fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
- g_free(wth->priv);
- wth->priv = NULL;
return -1;
}
@@ -377,8 +375,6 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
*err = file_error(wth->fh, err_info);
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
- g_free(wth->priv);
- wth->priv = NULL;
return -1;
}
@@ -419,8 +415,6 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
wth->file_encap = WTAP_ENCAP_TOKEN_RING;
break;
default:
- g_free(wth->priv);
- wth->priv = NULL;
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
*err_info = g_strdup_printf("lanalyzer: board type %u unknown",
board_type);
@@ -433,16 +427,12 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
/* Go back header number of bytes so that lanalyzer_read
* can read this header */
if (file_seek(wth->fh, -LA_RecordHeaderSize, SEEK_CUR, err) == -1) {
- g_free(wth->priv);
- wth->priv = NULL;
return -1;
}
return 1;
default:
if (file_seek(wth->fh, record_length, SEEK_CUR, err) == -1) {
- g_free(wth->priv);
- wth->priv = NULL;
return -1;
}
break;
diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c
index 018a35dbd3..cb9e97cf59 100644
--- a/wiretap/libpcap.c
+++ b/wiretap/libpcap.c
@@ -364,7 +364,6 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
* Well, we couldn't even read it.
* Give up.
*/
- g_free(wth->priv);
return -1;
case THIS_FORMAT:
@@ -373,7 +372,6 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
* Put the seek pointer back, and finish.
*/
if (file_seek(wth->fh, first_packet_offset, SEEK_SET, err) == -1) {
- g_free(wth->priv);
return -1;
}
goto done;
@@ -394,7 +392,6 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
*/
wth->file_type = WTAP_FILE_PCAP_SS990915;
if (file_seek(wth->fh, first_packet_offset, SEEK_SET, err) == -1) {
- g_free(wth->priv);
return -1;
}
} else {
@@ -416,7 +413,6 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
* Well, we couldn't even read it.
* Give up.
*/
- g_free(wth->priv);
return -1;
case THIS_FORMAT:
@@ -426,7 +422,6 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
* Put the seek pointer back, and finish.
*/
if (file_seek(wth->fh, first_packet_offset, SEEK_SET, err) == -1) {
- g_free(wth->priv);
return -1;
}
goto done;
@@ -445,7 +440,6 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
*/
wth->file_type = WTAP_FILE_PCAP_SS990417;
if (file_seek(wth->fh, first_packet_offset, SEEK_SET, err) == -1) {
- g_free(wth->priv);
return -1;
}
switch (libpcap_try(wth, err)) {
@@ -455,7 +449,6 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
* Well, we couldn't even read it.
* Give up.
*/
- g_free(wth->priv);
return -1;
case THIS_FORMAT:
@@ -464,7 +457,6 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
* Put the seek pointer back, and finish.
*/
if (file_seek(wth->fh, first_packet_offset, SEEK_SET, err) == -1) {
- g_free(wth->priv);
return -1;
}
goto done;
@@ -485,7 +477,6 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
*/
wth->file_type = WTAP_FILE_PCAP_NOKIA;
if (file_seek(wth->fh, first_packet_offset, SEEK_SET, err) == -1) {
- g_free(wth->priv);
return -1;
}
}
diff --git a/wiretap/netmon.c b/wiretap/netmon.c
index 0a7632475a..b026ae385f 100644
--- a/wiretap/netmon.c
+++ b/wiretap/netmon.c
@@ -329,14 +329,12 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("netmon: frame table length is %u, which is not a multiple of the size of an entry",
frame_table_length);
- g_free(netmon);
return -1;
}
if (frame_table_size == 0) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("netmon: frame table length is %u, which means it's less than one entry in size",
frame_table_length);
- g_free(netmon);
return -1;
}
/*
@@ -356,11 +354,9 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("netmon: frame table length is %u, which is larger than we support",
frame_table_length);
- g_free(netmon);
return -1;
}
if (file_seek(wth->fh, frame_table_offset, SEEK_SET, err) == -1) {
- g_free(netmon);
return -1;
}
frame_table = (guint32 *)g_malloc(frame_table_length);
@@ -371,7 +367,6 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
g_free(frame_table);
- g_free(netmon);
return -1;
}
netmon->frame_table_size = frame_table_size;
diff --git a/wiretap/nettl.c b/wiretap/nettl.c
index 1fa4034f24..564644426e 100644
--- a/wiretap/nettl.c
+++ b/wiretap/nettl.c
@@ -241,18 +241,12 @@ int nettl_open(wtap *wth, int *err, gchar **err_info)
bytes_read = file_read(dummy, 4, wth->fh);
if (bytes_read != 4) {
if (*err != 0) {
- wth->priv = NULL;
- g_free(nettl);
return -1;
}
if (bytes_read != 0) {
*err = WTAP_ERR_SHORT_READ;
- wth->priv = NULL;
- g_free(nettl);
return -1;
}
- wth->priv = NULL;
- g_free(nettl);
return 0;
}
@@ -290,7 +284,6 @@ int nettl_open(wtap *wth, int *err, gchar **err_info)
}
if (file_seek(wth->fh, FILE_HDR_SIZE, SEEK_SET, err) == -1) {
- g_free(nettl);
return -1;
}
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
diff --git a/wiretap/netxray.c b/wiretap/netxray.c
index 8acf26a86e..6fb6bbc1e0 100644
--- a/wiretap/netxray.c
+++ b/wiretap/netxray.c
@@ -901,7 +901,6 @@ int netxray_open(wtap *wth, int *err, gchar **err_info)
/* Seek to the beginning of the data records. */
if (file_seek(wth->fh, netxray->start_offset, SEEK_SET, err) == -1) {
- g_free(netxray);
return -1;
}