From Jakub Zawadzki:
authorstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 15 Mar 2009 18:08:46 +0000 (18:08 +0000)
committerstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 15 Mar 2009 18:08:46 +0000 (18:08 +0000)
More remove checking for NULL before g_free().

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@27728 f5534014-38df-0310-8fa8-9805f1628bb7

capture-pcap-util.c
epan/dissectors/packet-dcm.c
epan/dissectors/packet-smb.c
file.c
tap-protocolinfo.c
tshark.c
update.c
wiretap/k12.c

index 12cbcf1ccad4e94b1ad8ac322e2a934304d04017..f143a9586cb89e27f47bed9bf11aa28c3feb32ee 100644 (file)
@@ -336,8 +336,7 @@ free_if_cb(gpointer data, gpointer user_data _U_)
        if_info_t *if_info = data;
 
        g_free(if_info->name);
-       if (if_info->description != NULL)
-               g_free(if_info->description);
+       g_free(if_info->description);
 
        g_slist_foreach(if_info->ip_addr, free_if_info_addr_cb, NULL);
        g_slist_free(if_info->ip_addr);
@@ -550,8 +549,7 @@ free_linktype_cb(gpointer data, gpointer user_data _U_)
        data_link_info_t *linktype_info = data;
 
        g_free(linktype_info->name);
-       if (linktype_info->description != NULL)
-               g_free(linktype_info->description);
+       g_free(linktype_info->description);
 }
 
 void
index a2bbec038ef1151be6b9987b3f69ca5d3eeab56b..18f49b843b030bdcea410e8db3da7e9bf637b4c5 100644 (file)
@@ -4137,10 +4137,8 @@ dcm_set_syntax(dcm_state_pctx_t *pctx, gchar *xfer_uid, gchar *xfer_desc)
     if ((pctx == NULL) || (xfer_uid == NULL) || (xfer_desc == NULL))
        return;
 
-    if (pctx->xfer_uid != NULL)
-       g_free(pctx->xfer_uid);         /* free prev allocated xfer */
-    if (pctx->xfer_desc != NULL)
-       g_free(pctx->xfer_desc);        /* free prev allocated xfer */
+    g_free(pctx->xfer_uid);    /* free prev allocated xfer */
+    g_free(pctx->xfer_desc);   /* free prev allocated xfer */
 
     pctx->syntax = 0;
     pctx->xfer_uid = g_strdup(xfer_uid);
@@ -5540,7 +5538,7 @@ dissect_dcm_tag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
            vr = (gchar *)tvb_get_ephemeral_string(tvb, offset, 2);
            offset += 2;
 
-           if (pdv->open_tag.vr) g_free(pdv->open_tag.vr);     /* Free if needed */
+           g_free(pdv->open_tag.vr);
            pdv->open_tag.vr = g_strdup(vr);        /* needs to survive withing a session */
        }
 
index 1fb96eab918c5ad20c3025a5a04bb35cdbaa1fd9..56faa33ee5152f0314cf7e0c1b3d3e3a0e116f58 100644 (file)
@@ -1217,8 +1217,7 @@ TimeZoneFaster(time_t t)
                else
                        tdt = g_realloc(dst_table, sizeof(dst_table[0])*(i+1));
                if (tdt == NULL) {
-                       if (dst_table)
-                               g_free(dst_table);
+                       g_free(dst_table);
                        table_size = 0;
                } else {
                        dst_table = tdt;
diff --git a/file.c b/file.c
index 28fd5a9b99366d2b140312d72db80df583b92299..bea4c0cf53a72abcc72e861fce283e2308768bae 100644 (file)
--- a/file.c
+++ b/file.c
@@ -1438,8 +1438,7 @@ cf_filter_packets(capture_file *cf, gchar *dftext, gboolean force)
   }
 
   /* We have a valid filter.  Replace the current filter. */
-  if (cf->dfilter != NULL)
-    g_free(cf->dfilter);
+  g_free(cf->dfilter);
   cf->dfilter = dftext;
 
   /* Now rescan the packet list, applying the new filter, but not
@@ -2198,12 +2197,9 @@ cf_print_packets(capture_file *cf, print_args_t *print_args)
                                   "selected packets", TRUE, print_packet,
                                   &callback_args);
 
-  if (callback_args.header_line_buf != NULL)
-    g_free(callback_args.header_line_buf);
-  if (callback_args.line_buf != NULL)
-    g_free(callback_args.line_buf);
-  if (callback_args.col_widths != NULL)
-    g_free(callback_args.col_widths);
+  g_free(callback_args.header_line_buf);
+  g_free(callback_args.line_buf);
+  g_free(callback_args.col_widths);
 
   switch (ret) {
 
index 45ec4dcf7acaa0ef036813fae3cd25d3a57448cd..632949692ee3ca91424228d8ee4ce8696722b04e 100644 (file)
@@ -129,9 +129,7 @@ protocolinfo_init(const char *optarg, void* userdata _U_)
                fprintf(stderr, "tshark: Couldn't register proto,colinfo tap: %s\n",
                    error_string->str);
                g_string_free(error_string, TRUE);
-               if(rs->filter){
-                       g_free(rs->filter);
-               }
+               g_free(rs->filter);
                g_free(rs);
 
                exit(1);
index 81aff7dd61c04602b4ebbeea5ac4bd6c8627b543..9ce3f57582594e2d3c0a3b4fc538b825e1a6eca3 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -2313,8 +2313,7 @@ out:
   wtap_close(cf->wth);
   cf->wth = NULL;
 
-  if (save_file_string != NULL)
-    g_free(save_file_string);
+  g_free(save_file_string);
 
   return err;
 }
index 8aa636e1cc0504695116d42cc3d10fb1d2e9811e..4282bd88169bdaf732f6e1566bd1078977255039 100644 (file)
--- a/update.c
+++ b/update.c
@@ -118,23 +118,14 @@ update_info_new(void)
 void
 update_info_delete(update_info_t *update_info)
 {
-    if(update_info->prefix)
-        g_free(update_info->prefix);
-    if(update_info->version_installed)
-        g_free(update_info->version_installed);
-
-    if(update_info->title)
-        g_free(update_info->title);
-    if(update_info->description)
-        g_free(update_info->description);
-    if(update_info->version_recommended)
-        g_free(update_info->version_recommended);
-    if(update_info->url)
-        g_free(update_info->url);
-    if(update_info->md5)
-        g_free(update_info->md5);
-    if(update_info->size)
-        g_free(update_info->size);
+    g_free(update_info->prefix);
+    g_free(update_info->version_installed);
+    g_free(update_info->title);
+    g_free(update_info->description);
+    g_free(update_info->version_recommended);
+    g_free(update_info->url);
+    g_free(update_info->md5);
+    g_free(update_info->size);
 
     g_free(update_info);
 }
@@ -293,8 +284,7 @@ update_check_winpcap(const char *local_file)
     }
 
     g_string_free(pcap_version_tmp, TRUE);
-    if(pcap_version)
-        g_free(pcap_version);
+    g_free(pcap_version);
 
     return update_info;
 }
index 5c735c5fefdda57eefe38771ce56f997c80303c0..6e83b75733d292bb1a518f8b15fc670c04c1c749 100644 (file)
@@ -543,12 +543,8 @@ static k12_t* new_k12_file_data(void) {
 static gboolean destroy_srcdsc(gpointer k _U_, gpointer v, gpointer p _U_) {
     k12_src_desc_t* rec = v;
 
-    if(rec->input_name)
-        g_free(rec->input_name);
-
-    if(rec->stack_file)
-        g_free(rec->stack_file);
-
+    g_free(rec->input_name);
+    g_free(rec->stack_file);
     g_free(rec);
 
     return TRUE;