Fix crash when doing "tshark -2 -r file -w newfile".

We were using cf->buf in some places and a local variable buf in others;
consistenly use the local variable.

Have a local variable for the struct wtap_pkthdr while we're at it; with
some work we may be able to get rid of the struct wtap_pkthdr and the
Buffer in the capture_file structure.

Change-Id: I4762e22e11ef576be6bf9015450d1a270dd3d16b
Reviewed-on: https://code.wireshark.org/review/178
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2014-02-11 11:49:24 -08:00
parent 648769497a
commit 114d051aef
1 changed files with 5 additions and 4 deletions

View File

@ -3024,6 +3024,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
wtapng_section_t *shb_hdr;
wtapng_iface_descriptions_t *idb_inf;
char appname[100];
struct wtap_pkthdr phdr;
Buffer buf;
epan_dissect_t *edt = NULL;
@ -3190,15 +3191,15 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
for (framenum = 1; err == 0 && framenum <= cf->count; framenum++) {
fdata = frame_data_sequence_find(cf->frames, framenum);
if (wtap_seek_read(cf->wth, fdata->file_off, &cf->phdr,
&buf, &err, &err_info)) {
if (process_packet_second_pass(cf, edt, fdata, &cf->phdr, &buf,
if (wtap_seek_read(cf->wth, fdata->file_off, &phdr, &buf, &err,
&err_info)) {
if (process_packet_second_pass(cf, edt, fdata, &phdr, &buf,
tap_flags)) {
/* Either there's no read filtering or this packet passed the
filter, so, if we're writing to a capture file, write
this packet out. */
if (pdh != NULL) {
if (!wtap_dump(pdh, &cf->phdr, buffer_start_ptr(&cf->buf), &err)) {
if (!wtap_dump(pdh, &phdr, buffer_start_ptr(&buf), &err)) {
/* Error writing to a capture file */
switch (err) {