From fc22af941cf7b9db65a703e9e697490119c70ec2 Mon Sep 17 00:00:00 2001 From: Andreas Fink Date: Fri, 8 Oct 2010 21:45:14 +0000 Subject: [PATCH] *fix* valgrind invalid read/write and memleaks --- src/clock/clock.c | 1 + src/config.c | 38 ++++++++++++++++++++++++-------------- src/server.c | 2 +- src/systray/systraybar.c | 5 +++++ src/tint.c | 2 +- src/util/timer.c | 1 + 6 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/clock/clock.c b/src/clock/clock.c index 6ce24b8..500cfa3 100644 --- a/src/clock/clock.c +++ b/src/clock/clock.c @@ -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); } diff --git a/src/config.c b/src/config.c index 8170631..dc4a30a 100644 --- a/src/config.c +++ b/src/config.c @@ -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; diff --git a/src/server.c b/src/server.c index 053b41f..f35bb96 100644 --- a/src/server.c +++ b/src/server.c @@ -303,7 +303,7 @@ void get_monitors() i++; } next: - for (j=i; jrender_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 diff --git a/src/tint.c b/src/tint.c index 22f67da..529e3cd 100644 --- a/src/tint.c +++ b/src/tint.c @@ -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); } diff --git a/src/util/timer.c b/src/util/timer.c index 01bd768..dd68473 100644 --- a/src/util/timer.c +++ b/src/util/timer.c @@ -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); -- 2.43.0