Eliminate some double-frees.
authorGuy Harris <guy@alum.mit.edu>
Sat, 29 Apr 2017 11:28:53 +0000 (04:28 -0700)
committerGuy Harris <guy@alum.mit.edu>
Sat, 29 Apr 2017 11:29:34 +0000 (11:29 +0000)
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>
capinfos.c
file.c
mergecap.c
tshark.c
wiretap/wtap.c

index f0498646739a42ec79a9a4c7d2c87230b6f25f27..428093c2c9fae067a48f930662e847a60f847f0d 100644 (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;
     }
diff --git a/file.c b/file.c
index 72771c46be0e645595c7775a3a9561a96e2b84d4..f5e39f6581e35ba9b58ed82b27809221423532b6 100644 (file)
--- a/file.c
+++ b/file.c
@@ -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) {
index cac00af45e15f8f83e3982ef88a99f77067bbd9f..e696c0042fc9926293b087130d168bb7aee88d8e 100644 (file)
@@ -494,8 +494,6 @@ main(int argc, char *argv[])
       break;
   }
 
-  g_free(err_info);
-
 clean_exit:
   wtap_cleanup();
   free_progdirs();
index 7fc59383853243f1b38de8322dae3be4d67b1477..071e5d8776a26ce17df5ce496a9c0b047d5085a7 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -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;
   }
index 1b9ab0552abcc0a294b523e534bdae73b61b5079..58a22e92982ab8939a47d7865b26325bb39ec270 100644 (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;