Fix version-string releated memleak for some CLI tools
authorPeter Wu <peter@lekensteyn.nl>
Fri, 9 Sep 2016 23:27:28 +0000 (01:27 +0200)
committerPeter Wu <peter@lekensteyn.nl>
Sat, 10 Sep 2016 13:00:22 +0000 (13:00 +0000)
These programs resulted on a memleak report on exit.

Change-Id: I630618f50d723b7af4cb00ba29671d4e7c6fcdc2
Reviewed-on: https://code.wireshark.org/review/17623
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
captype.c
mergecap.c
text2pcap.c
tfshark.c

index d83b21485c4675f369bedaf0caef24710cdb74af..87e4f92d2a91979c4d38b26d79974363639fedc6 100644 (file)
--- a/captype.c
+++ b/captype.c
@@ -118,6 +118,8 @@ main(int argc, char *argv[])
          "\n"
          "%s",
       get_ws_vcs_version_info(), comp_info_str->str, runtime_info_str->str);
+  g_string_free(comp_info_str, TRUE);
+  g_string_free(runtime_info_str, TRUE);
 
 #ifdef _WIN32
   arg_list_utf_16to8(argc, argv);
@@ -168,6 +170,8 @@ main(int argc, char *argv[])
         break;
 
       case 'v':
+        comp_info_str = get_compiled_version_info(NULL, NULL);
+        runtime_info_str = get_runtime_version_info(NULL);
         show_version("Captype (Wireshark)", comp_info_str, runtime_info_str);
         g_string_free(comp_info_str, TRUE);
         g_string_free(runtime_info_str, TRUE);
index 089ef0254daa28d246f8ae3ee5271647b0f9b3a9..1476e0fe5df43974b2bcc429a3ac0c6818771688 100644 (file)
@@ -291,6 +291,8 @@ main(int argc, char *argv[])
        "\n"
        "%s",
     get_ws_vcs_version_info(), comp_info_str->str, runtime_info_str->str);
+  g_string_free(comp_info_str, TRUE);
+  g_string_free(runtime_info_str, TRUE);
 
   /*
    * Get credential information for later use.
@@ -368,6 +370,8 @@ main(int argc, char *argv[])
       break;
 
     case 'V':
+      comp_info_str = get_compiled_version_info(NULL, NULL);
+      runtime_info_str = get_runtime_version_info(NULL);
       show_version("Mergecap (Wireshark)", comp_info_str, runtime_info_str);
       g_string_free(comp_info_str, TRUE);
       g_string_free(runtime_info_str, TRUE);
index d364984d62f1ebb6d76c92c1aaae8eba3234aa9a..855df5e54caaab2c57df1cb8d774dff48b43364d 100644 (file)
@@ -1467,6 +1467,8 @@ parse_options (int argc, char *argv[])
          "\n"
          "%s",
       get_ws_vcs_version_info(), comp_info_str->str, runtime_info_str->str);
+    g_string_free(comp_info_str, TRUE);
+    g_string_free(runtime_info_str, TRUE);
 
     /* Scan CLI parameters */
     while ((c = getopt_long(argc, argv, "aDdhqe:i:l:m:no:u:s:S:t:T:v4:6:", long_options, NULL)) != -1) {
@@ -1675,6 +1677,8 @@ parse_options (int argc, char *argv[])
             break;
 
         case 'v':
+            comp_info_str = get_compiled_version_info(NULL, NULL);
+            runtime_info_str = get_runtime_version_info(NULL);
             show_version("Text2pcap (Wireshark)", comp_info_str, runtime_info_str);
             g_string_free(comp_info_str, TRUE);
             g_string_free(runtime_info_str, TRUE);
index 49cb26ab061703d902936bac033b82c6f90b1811..bc7323eee6eed73844ddbb83cf9e6b24486b76d3 100644 (file)
--- a/tfshark.c
+++ b/tfshark.c
@@ -420,6 +420,8 @@ main(int argc, char *argv[])
          "\n"
          "%s",
       get_ws_vcs_version_info(), comp_info_str->str, runtime_info_str->str);
+  g_string_free(comp_info_str, TRUE);
+  g_string_free(runtime_info_str, TRUE);
 
   /*
    * In order to have the -X opts assigned before the wslua machine starts
@@ -854,7 +856,8 @@ main(int argc, char *argv[])
       }
       break;
     case 'v':         /* Show version and exit */
-    {
+      comp_info_str = get_compiled_version_info(NULL, epan_get_compiled_version_info);
+      runtime_info_str = get_runtime_version_info(get_tfshark_runtime_version_info);
       show_version("TFShark (Wireshark)", comp_info_str, runtime_info_str);
       g_string_free(comp_info_str, TRUE);
       g_string_free(runtime_info_str, TRUE);
@@ -868,7 +871,6 @@ main(int argc, char *argv[])
 #endif
       epan_cleanup();
       return 0;
-    }
     case 'O':        /* Only output these protocols */
       /* already processed; just ignore it now */
       break;