print_stream: free memory on exit.

Change-Id: I6c4acaa9026cfdf1d4230c28c30bccfb6c025cef
Reviewed-on: https://code.wireshark.org/review/19920
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
This commit is contained in:
Dario Lombardo 2017-02-09 18:06:45 +01:00
parent d4cf57100c
commit a29fe9d76a
4 changed files with 5 additions and 2 deletions

View File

@ -98,7 +98,7 @@ print_finale(print_stream_t *self)
gboolean
destroy_print_stream(print_stream_t *self)
{
return self->ops->destroy ? (self->ops->destroy)(self) : TRUE;
return (self && self->ops && self->ops->destroy) ? (self->ops->destroy)(self) : TRUE;
}
typedef struct {

View File

@ -1054,6 +1054,7 @@ main(int argc, char *argv[])
funnel_dump_all_text_windows();
clean_exit:
destroy_print_stream(print_stream);
epan_free(cfile.epan);
epan_cleanup();
#ifdef HAVE_EXTCAP

View File

@ -185,7 +185,7 @@ static gboolean line_buffered;
static gboolean really_quiet = FALSE;
static print_format_e print_format = PR_FMT_TEXT;
static print_stream_t *print_stream;
static print_stream_t *print_stream = NULL;
static output_fields_t* output_fields = NULL;
static gchar **protocolfilter = NULL;
@ -2205,6 +2205,7 @@ main(int argc, char *argv[])
output_fields = NULL;
clean_exit:
destroy_print_stream(print_stream);
#ifdef HAVE_LIBPCAP
capture_opts_cleanup(&global_capture_opts);
#endif

View File

@ -684,6 +684,7 @@ win32_export_file(HWND h_wnd, capture_file *cf, export_type_e export_type) {
print_args.print_dissections = print_dissections_as_displayed;
print_args.print_hex = FALSE;
print_args.print_formfeed = FALSE;
print_args.stream = NULL;
if (GetSaveFileName(ofn)) {
print_args.file = utf_16to8(file_name);