[Xfce4-commits] [panel-plugins/xfce4-sensors-plugin] 10/11: More secure stand-aone application with less memory leaks
noreply at xfce.org
noreply at xfce.org
Tue Mar 7 23:38:34 CET 2017
This is an automated email from the git hooks/post-receive script.
timystery pushed a commit to branch master
in repository panel-plugins/xfce4-sensors-plugin.
commit 9b7b7b9b2ba6447c58fdb7d5a2cd153b42c93036
Author: Fabian <timystery at arcor.de>
Date: Tue Mar 7 22:10:39 2017 +0100
More secure stand-aone application with less memory leaks
---
src/actions.c | 9 ++++++++-
src/callbacks.c | 4 ++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/actions.c b/src/actions.c
index 5d6ee80..8356c41 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -136,10 +136,16 @@ refresh_tacho_view (t_sensors_dialog *ptr_sensors_dialog_structure)
// actually, the idea is to move the tacho widgets in the table; but Gtk fails at this point:
// there is neither a gtk_table_move nor does it allow to unparent a widget and attach it at a new positon,
// so the container is removed and destroyed for safety.
+ // Similarly, the strdupped texts are freed.
if ( (ptr_sensors_structure->tachos [idx_chip][idx_feature] != NULL)
&& (gtk_widget_get_parent(ptr_sensors_structure->tachos [idx_chip][idx_feature]) != NULL) )
{
gtk_container_remove(GTK_CONTAINER(ptr_wdgt_table), ptr_sensors_structure->tachos [idx_chip][idx_feature]);
+ if (GTK_SENSORSTACHO(ptr_sensors_structure->tachos [idx_chip][idx_feature])->text)
+ g_free(GTK_SENSORSTACHO(ptr_sensors_structure->tachos [idx_chip][idx_feature])->text);
+
+ if (GTK_SENSORSTACHO(ptr_sensors_structure->tachos [idx_chip][idx_feature])->color)
+ g_free(GTK_SENSORSTACHO(ptr_sensors_structure->tachos [idx_chip][idx_feature])->color);
}
ptr_sensors_structure->tachos[idx_chip][idx_feature] = gtk_sensorstacho_new(ptr_sensors_structure->orientation, 48);
@@ -152,9 +158,10 @@ refresh_tacho_view (t_sensors_dialog *ptr_sensors_dialog_structure)
GTK_SENSORSTACHO(ptr_sensors_structure->tachos [idx_chip][idx_feature])->sel = val_fill_degree;
snprintf(str_widget_tooltip_text, 128, "<b>%s</b>\n%s: %s", ptr_chip_structure->sensorId, ptr_chipfeature_structure->name, ptr_chipfeature_structure->formatted_value);
gtk_widget_set_tooltip_markup (GTK_WIDGET(ptr_sensors_structure->tachos [idx_chip][idx_feature]), str_widget_tooltip_text);
+
GTK_SENSORSTACHO(ptr_sensors_structure->tachos [idx_chip][idx_feature])->text = g_strdup(ptr_chipfeature_structure->name);
- GTK_SENSORSTACHO(ptr_sensors_structure->tachos [idx_chip][idx_feature])->color = g_strdup(ptr_chipfeature_structure->color);
+ GTK_SENSORSTACHO(ptr_sensors_structure->tachos [idx_chip][idx_feature])->color = g_strdup(ptr_chipfeature_structure->color);
//gtk_widget_set_size_request(ptr_sensors_structure->tachos [idx_chip][idx_feature], 64, 64);
diff --git a/src/callbacks.c b/src/callbacks.c
index 5f0ecb9..b321560 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -194,6 +194,10 @@ list_cell_toggle_ (GtkCellRendererToggle *cell, gchar *path_str,
gtk_container_remove(GTK_CONTAINER(sd->sensors->widget_sensors),
sd->sensors->tachos [gtk_combo_box_active][atoi(path_str)]);
//gtk_widget_destroy(sd->sensors->tachos [gtk_combo_box_active][atoi(path_str)]);
+ if (GTK_SENSORSTACHO(sd->sensors->tachos [gtk_combo_box_active][atoi(path_str)])->text)
+ g_free(GTK_SENSORSTACHO(sd->sensors->tachos [gtk_combo_box_active][atoi(path_str)])->text);
+ if (GTK_SENSORSTACHO(sd->sensors->tachos [gtk_combo_box_active][atoi(path_str)])->color)
+ g_free(GTK_SENSORSTACHO(sd->sensors->tachos [gtk_combo_box_active][atoi(path_str)])->color);
sd->sensors->tachos [gtk_combo_box_active][atoi(path_str)] = NULL;
}
//else
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list