[gnome-control-center] wacom: Fix out-of-scope usage
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] wacom: Fix out-of-scope usage
- Date: Tue, 10 Jan 2012 19:58:47 +0000 (UTC)
commit 7533c6876bfe62b1a02eb79904d04109af4868d0
Author: Bastien Nocera <hadess hadess net>
Date: Tue Jan 10 19:43:08 2012 +0000
wacom: Fix out-of-scope usage
The output of g_variant_get_fixed_array() is only valid as long
as the GVariant is valid. Outside the function, anything goes.
panels/wacom/cc-wacom-page.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/panels/wacom/cc-wacom-page.c b/panels/wacom/cc-wacom-page.c
index 82dcead..ef3fe6b 100644
--- a/panels/wacom/cc-wacom-page.c
+++ b/panels/wacom/cc-wacom-page.c
@@ -119,8 +119,11 @@ get_calibration (gint ** cal,
gsize * ncal,
GSettings * settings)
{
+ gconstpointer res;
+
GVariant *current = g_settings_get_value (settings, "area");
- *cal = g_variant_get_fixed_array (current, ncal, sizeof (gint32));
+ res = g_variant_get_fixed_array (current, ncal, sizeof (gint32));
+ *cal = g_memdup (res, *ncal * sizeof (gint32));
}
static void
@@ -208,6 +211,7 @@ calibrate_button_clicked_cb (GtkButton *button, gpointer user_data)
if (s != 4)
{
g_warning("Device calibration property has wrong length. Got %d items; expected %d.\n", s, 4);
+ g_free (current);
return;
}
@@ -219,6 +223,8 @@ calibrate_button_clicked_cb (GtkButton *button, gpointer user_data)
if (run_calibration(calibration, 4))
set_calibration(calibration, 4, tablet);
+
+ g_free (current);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]