]> Dogcows Code - chaz/tint2/commitdiff
*fix* valgrind invalid read/write and memleaks
authorAndreas Fink <andreas.fink85@googlemail.com>
Fri, 8 Oct 2010 21:45:14 +0000 (21:45 +0000)
committerAndreas Fink <andreas.fink85@googlemail.com>
Fri, 8 Oct 2010 21:45:14 +0000 (21:45 +0000)
src/clock/clock.c
src/config.c
src/server.c
src/systray/systraybar.c
src/tint.c
src/util/timer.c

index 6ce24b8d18194ea5712dc2153ccddac44e69918e..500cfa3ba8556f82a8e30ac0afe688caa861c5b2 100644 (file)
@@ -78,6 +78,7 @@ void cleanup_clock()
        if (time_tooltip_timezone) g_free(time_tooltip_timezone);
        if (clock_lclick_command) g_free(clock_lclick_command);
        if (clock_rclick_command) g_free(clock_rclick_command);
+       if (clock_timeout) stop_timeout(clock_timeout);
 }
 
 
index 8170631cc12941e8570390a4763f5ee8084cfa98..dc4a30ace2397a89e60b99afc111edf3e164c883 100644 (file)
@@ -375,10 +375,13 @@ void add_entry (char *key, char *value)
        else if (strcmp (key, "time1_format") == 0) {
                if (new_config_file == 0) {
                        clock_enabled = 1;
-                       if (panel_items_order)
-                               panel_items_order = strcat(panel_items_order, "C");
+                       if (panel_items_order) {
+                               char* tmp = g_strconcat(panel_items_order, "C", NULL);
+                               g_free( panel_items_order );
+                               panel_items_order = tmp;
+                       }
                        else 
-                               panel_items_order = strdup("C");
+                               panel_items_order = g_strdup("C");
                }
                if (strlen(value) > 0) {
                        time1_format = strdup (value);
@@ -658,10 +661,13 @@ void add_entry (char *key, char *value)
                if (new_config_file == 0) {
                        systray_enabled = atoi(value);
                        if (systray_enabled) {
-                               if (panel_items_order)
-                                       panel_items_order = strcat(panel_items_order, "S");
-                               else 
-                                       panel_items_order = strdup("S");
+                               if (panel_items_order) {
+                                       char* tmp = g_strconcat(panel_items_order, "S", NULL);
+                                       g_free( panel_items_order );
+                                       panel_items_order = tmp;
+                               }
+                               else
+                                       panel_items_order = g_strdup("S");
                        }
                }
        }
@@ -669,10 +675,13 @@ void add_entry (char *key, char *value)
                if (new_config_file == 0) {
                        battery_enabled = atoi(value);
                        if (battery_enabled) {
-                               if (panel_items_order)
-                                       panel_items_order = strcat(panel_items_order, "B");
-                               else 
-                                       panel_items_order = strdup("B");
+                               if (panel_items_order) {
+                                       char* tmp = g_strconcat(panel_items_order, "B", NULL);
+                                       g_free( panel_items_order );
+                                       panel_items_order = tmp;
+                               }
+                               else
+                                       panel_items_order = g_strdup("B");
                        }
                }
        }
@@ -753,11 +762,12 @@ int config_read_file (const char *path)
        if (new_config_file == 0) {
                taskbar_enabled = 1;
                if (panel_items_order) {
-                       char *tmp = strdup("T");
-                       panel_items_order = strcat(tmp, panel_items_order);
+                       char* tmp = g_strconcat( "T", panel_items_order, NULL );
+                       g_free(panel_items_order);
+                       panel_items_order = tmp;
                }
                else 
-                       panel_items_order = strdup("T");
+                       panel_items_order = g_strdup("T");
        }
 
        return 1;
index 053b41f29d43fe287526c7631cb022451decf90b..f35bb964c281113cf78f5b4cea151fb950a98418 100644 (file)
@@ -303,7 +303,7 @@ void get_monitors()
                        i++;
                }
 next:
-               for (j=i; j<server.nb_monitor; ++j)
+               for (j=i; j<nbmonitor; ++j)
                        if (server.monitor[j].names)
                                g_strfreev(server.monitor[j].names);
                server.nb_monitor = i;
index 23d2ab3821d1b58883ed1a0a380dd36a1bea2626..8a840ce7130a11499a1b058e554c54c1ffbd1200 100644 (file)
@@ -532,6 +532,11 @@ void systray_render_icon_now(void* t)
        // we made also sure, that we always have a 32 bit visual, i.e. we can safely create 32 bit pixmaps here
        TrayWindow* traywin = t;
        traywin->render_timeout = 0;
+       if ( traywin->width == 0 || traywin->height == 0 ) {
+               // reschedule rendering since the geometry information has not yet been processed (can happen on slow cpu)
+               systray_render_icon(traywin);
+               return;
+       }
 
        // good systray icons support 32 bit depth, but some icons are still 24 bit.
        // We create a heuristic mask for these icons, i.e. we get the rgb value in the top left corner, and
index 22f67da01d76b7ea5cc4aff2914d976ed646fa06..529e3cda0119a3d18bdaa829084bd10aeebcfeed 100644 (file)
@@ -156,7 +156,6 @@ void init_X11()
 
 void cleanup()
 {
-       cleanup_timeout();
        cleanup_systray();
        cleanup_tooltip();
        cleanup_clock();
@@ -174,6 +173,7 @@ void cleanup()
        imlib_context_disconnect_display();
 
        cleanup_server();
+       cleanup_timeout();
        if (server.dsp) XCloseDisplay(server.dsp);
 }
 
index 01bd7686b972783b2bd324641fde78b9bf3eaa74..dd6847318569126796964e3caea4f70b64d0df44 100644 (file)
@@ -398,6 +398,7 @@ void remove_from_multi_timeout(timeout* t)
 
        if (g_slist_length(mth->timeout_list) == 1) {
                timeout* last_timeout = mth->timeout_list->data;
+               g_slist_remove(mth->timeout_list, last_timeout);
                free(last_timeout->multi_timeout);
                last_timeout->multi_timeout = 0;
                g_hash_table_remove(multi_timeouts, last_timeout);
This page took 0.029021 seconds and 4 git commands to generate.