[Xfce4-commits] <xfce4-generic-slider:master> Be more careful about freeing empty strings

Connor Behan noreply at xfce.org
Wed Nov 14 04:46:01 CET 2012


Updating branch refs/heads/master
         to f7521d874e96def7abdf0bf6e5fa72dfc8652054 (commit)
       from 63f1447a479ed2850d5e27249215b62c94c0c1ea (commit)

commit f7521d874e96def7abdf0bf6e5fa72dfc8652054
Author: Connor Behan <connor.behan at gmail.com>
Date:   Tue Nov 13 19:45:22 2012 -0800

    Be more careful about freeing empty strings

 generic-slider.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/generic-slider.c b/generic-slider.c
index e92a19b..f3f12e0 100644
--- a/generic-slider.c
+++ b/generic-slider.c
@@ -34,7 +34,12 @@ char *parse_command(char *primitive, int value, int delta) {
 	int numvs = 0;
 	int i;
 	
-	if (!strcmp(primitive, "")) return "";
+	if (!strcmp(primitive, "")) {
+		/* Functions that free this string later need something to free */
+		char *command = malloc(sizeof(char));
+		strcpy(command, "");
+		return command;
+	}
 	
 	for (i = 0; i < strlen(primitive); i++) {
 		if (primitive[i-1] == '%') {
@@ -232,6 +237,7 @@ static gint scroll_slider_cb(GtkWidget *widget, GdkEventScroll *event, GList *st
 	gtk_label_set_text(GTK_LABEL(generic_slider -> label), label_text);
 	gtk_widget_set_tooltip_text(generic_slider -> slider, label_text);
 	gtk_widget_set_tooltip_text(generic_slider -> label, label_text);
+	free(label_text);
 	return TRUE;
 }
 
@@ -265,6 +271,7 @@ static gint adjust_slider_cb(GtkWidget *widget, GdkEventButton *event, GList *st
 		gtk_label_set_text(GTK_LABEL(generic_slider -> label), label_text);
 		gtk_widget_set_tooltip_text(generic_slider -> slider, label_text);
 		gtk_widget_set_tooltip_text(generic_slider -> label, label_text);
+		free(label_text);
 	}
 	
 	return FALSE;
@@ -474,6 +481,7 @@ static void generic_slider_update_commands(GtkWidget *entry, Generic_Slider *gen
 		gtk_label_set_text(GTK_LABEL(generic_slider -> label), label_text);
 		gtk_widget_set_tooltip_text(generic_slider -> slider, label_text);
 		gtk_widget_set_tooltip_text(generic_slider -> label, label_text);
+		free(label_text);
 	}
 }
 
@@ -813,6 +821,7 @@ static void generic_slider_construct(XfcePanelPlugin *plugin) {
 	gtk_label_set_text(GTK_LABEL(label), label_text);
 	gtk_widget_set_tooltip_text(slider, label_text);
 	gtk_widget_set_tooltip_text(label, label_text);
+	free(label_text);
 	
 	if ((generic_slider -> mode) == 1) {
 		gtk_widget_hide(label);


More information about the Xfce4-commits mailing list