Eliminate some double-frees.

The cfile_ error-reporting routines free err_info; the caller doesn't
have to and, in fact, mustn't do so themselves.

While we're at it, make sure wtap_seek_read() always zeroes out *err and
nulls out *err_info, so the latter either points to a freshly-allocated
string or is null.

Change-Id: Idfe05a3ba2fbf2647ba14e483187617ee53e3c69
Reviewed-on: https://code.wireshark.org/review/21407
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2017-04-29 04:28:53 -07:00
parent e3f49280de
commit 2a3f1a4f67
5 changed files with 2 additions and 11 deletions

View File

@ -1231,11 +1231,6 @@ process_cap_file(wtap *wth, const char *filename)
fprintf(stderr,
" (will continue anyway, checksums might be incorrect)\n");
} else {
if (err_info != NULL) {
fprintf(stderr, "(%s)\n", err_info);
g_free(err_info);
}
cleanup_capture_info(&cf_info);
return 1;
}

2
file.c
View File

@ -1411,8 +1411,6 @@ cf_merge_files_to_tempfile(gpointer pd_window, char **out_filenamep,
break;
}
g_free(err_info);
cf_callback_invoke(cf_cb_file_merge_finished, NULL);
if (status != MERGE_OK) {

View File

@ -494,8 +494,6 @@ main(int argc, char *argv[])
break;
}
g_free(err_info);
clean_exit:
wtap_cleanup();
free_progdirs();

View File

@ -3317,13 +3317,11 @@ process_cap_file(capture_file *cf, char *save_file, int out_file_type,
/* Error on pass 1 of two-pass processing. */
cfile_read_failure_message("TShark", cf->filename, err_pass1,
err_info_pass1);
g_free(err_info_pass1);
}
if (err != 0) {
/* Error on pass 2 of two-pass processing or on the only pass of
one-pass processing. */
cfile_read_failure_message("TShark", cf->filename, err, err_info);
g_free(err_info);
}
success = FALSE;
}

View File

@ -1403,6 +1403,8 @@ wtap_seek_read(wtap *wth, gint64 seek_off,
phdr->pkt_encap = wth->file_encap;
phdr->pkt_tsprec = wth->file_tsprec;
*err = 0;
*err_info = NULL;
if (!wth->subtype_seek_read(wth, seek_off, phdr, buf, err, err_info))
return FALSE;