aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss@ulticom.com>2012-03-14 01:08:09 +0000
committerJeff Morriss <jeff.morriss@ulticom.com>2012-03-14 01:08:09 +0000
commit603b4d43486e6ecf06f93182a4bbee2b9678a9cb (patch)
tree26110b9e3aac7ee67a48d552fa78ee1ae3231a0d
parente60c1286b26e61eacfa302d815553cd977205776 (diff)
Don't free idb_inf in wtap_dump_open_ng(): free it in the callers. This fixes the double-free editcap crashes that the buildbot's been seeing lately.
svn path=/trunk/; revision=41542
-rw-r--r--editcap.c5
-rw-r--r--tshark.c6
-rw-r--r--wiretap/file_access.c1
3 files changed, 7 insertions, 5 deletions
diff --git a/editcap.c b/editcap.c
index 3d75f4281b..1837a0e736 100644
--- a/editcap.c
+++ b/editcap.c
@@ -1155,11 +1155,15 @@ main(int argc, char *argv[])
pdh = wtap_dump_open_ng(filename, out_file_type, out_frame_type,
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
FALSE /* compressed */, shb_hdr, idb_inf, &err);
+
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n", filename,
wtap_strerror(err));
exit(2);
}
+
+ g_free(idb_inf);
+ idb_inf = NULL;
}
g_assert(filename);
@@ -1522,7 +1526,6 @@ main(int argc, char *argv[])
exit(2);
}
- g_free(idb_inf);
g_free(shb_hdr);
g_free(filename);
}
diff --git a/tshark.c b/tshark.c
index d1cd96f470..1918ae1e3a 100644
--- a/tshark.c
+++ b/tshark.c
@@ -2711,6 +2711,9 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
pdh = wtap_dump_open_ng(save_file, out_file_type, linktype, snapshot_length,
FALSE /* compressed */, shb_hdr, idb_inf, &err);
+ g_free(idb_inf);
+ idb_inf = NULL;
+
if (pdh == NULL) {
/* We couldn't set up to write to the capture file. */
switch (err) {
@@ -2833,7 +2836,6 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
break;
}
wtap_dump_close(pdh, &err);
- g_free(idb_inf);
g_free(shb_hdr);
exit(2);
}
@@ -2885,7 +2887,6 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
break;
}
wtap_dump_close(pdh, &err);
- g_free(idb_inf);
g_free(shb_hdr);
exit(2);
}
@@ -2993,7 +2994,6 @@ out:
cf->wth = NULL;
g_free(save_file_string);
- g_free(idb_inf);
g_free(shb_hdr);
return err;
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index 5675cc22ef..d4ddd6f735 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -1009,7 +1009,6 @@ wtap_dumper* wtap_dump_open_ng(const char *filename, int filetype, int encap,
if ((idb_inf != NULL) && (idb_inf->number_of_interfaces > 0)) {
wdh->number_of_interfaces = idb_inf->number_of_interfaces;
wdh->interface_data = idb_inf->interface_data;
- g_free(idb_inf);
} else {
wtapng_if_descr_t descr;