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
This commit is contained in:
Jeff Morriss 2012-03-14 01:08:09 +00:00
parent e60c1286b2
commit 603b4d4348
3 changed files with 7 additions and 5 deletions

View File

@ -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);
}

View File

@ -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;

View File

@ -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;