Bugfix: segfault with wrong config
authorNikolas Garofil <garo@dunaldi.garofil.be>
Wed, 13 May 2009 18:25:14 +0000 (20:25 +0200)
committerNikolas Garofil <garo@dunaldi.garofil.be>
Wed, 13 May 2009 18:25:14 +0000 (20:25 +0200)
Altough the following configuration is wrong, it should only produce a error
about a missing $endif but instead it also produced a segmentation fault:

TEXT
$if_gw$gw_ip$else

src/conky.c

index 78f1b25..f7ce451 100644 (file)
@@ -3260,7 +3260,8 @@ static void generate_text_internal(char *p, int p_max_size,
 #endif
 
        p[0] = 0;
-       for (obj = root.next; obj && p_max_size > 0; obj = obj->next) {
+       obj = root.next;
+       while (obj && p_max_size > 0) {
                needed = 0; // reset for top stuff
 
 /* IFBLOCK jumping algorithm
@@ -5265,6 +5266,7 @@ static void generate_text_internal(char *p, int p_max_size,
                        p += a;
                        p_max_size -= a;
                }
+               obj = obj->next;
        }
 }