ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: [Wireshark-dev] Bug #1203 fix: Top coloring rule doesn't work

From: Stephen Fisher <stephentfisher@xxxxxxxxx>
Date: Mon, 6 Nov 2006 15:03:10 -0800
Attached is a patch to fix bug #1203: "The rule on top of the coloring 
rule list is not executed"

I changed g_slist_next to g_slist_nth with a counter variable starting 
at 0 to fix this problem.  This is because the first call to 
g_slist_next (while on the first entry in the list) takes you right to 
second entry in the list:

>From /usr/local/include/glib-2.0/glib/gslist.h:

#define g_slist_next(slist)  ((slist) ? (((GSList *)(slist))->next) : 
 NULL)


Thanks,
  Steve


Index: color_filters.c
===================================================================
--- color_filters.c	(revision 19835)
+++ color_filters.c	(working copy)
@@ -251,12 +251,13 @@
 {
     GSList *curr;
     color_filter_t *colorf;
+    gint counter = 0;
 
     /* If we have color filters, "search" for the matching one. */
     if (color_filters_used()) {
         curr = color_filter_list;
 
-        while( (curr = g_slist_next(curr)) != NULL) {
+        while( (curr = g_slist_nth(curr, counter)) != NULL) {
             colorf = curr->data;
             if ((colorf->c_colorfilter != NULL) &&
                  dfilter_apply_edt(colorf->c_colorfilter, edt)) {
@@ -264,6 +265,7 @@
                     packet_list_set_colors(row, &(colorf->fg_color), &(colorf->bg_color));
                     return colorf;
             }
+	    counter++;
         }
     }