[gnome-settings-daemon] power: Fix a crash when reading invalid backlight values



commit 631cd5ff8350fbd20d96bd6b48f3c4136e3c5e0f
Author: Rui Matos <tiagomatos gmail com>
Date:   Fri May 15 15:44:58 2015 +0200

    power: Fix a crash when reading invalid backlight values
    
    If atoi() returns a negative value this will be interpreted as an
    error but the GError wouldn't be set which would crash us when
    printing an error message.
    
    See https://bugzilla.redhat.com/show_bug.cgi?id=1222007
    
    https://bugzilla.gnome.org/show_bug.cgi?id=749440

 plugins/power/gsd-backlight-helper.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/plugins/power/gsd-backlight-helper.c b/plugins/power/gsd-backlight-helper.c
index 0714207..00bc263 100644
--- a/plugins/power/gsd-backlight-helper.c
+++ b/plugins/power/gsd-backlight-helper.c
@@ -89,6 +89,9 @@ gsd_backlight_helper_read_value (const gchar *filename, GError **error)
                value = -1;
        g_free (contents);
 
+       if (value < 0 && *error == NULL)
+               g_set_error (error, 1, 0, "got invalid backlight value from %s", filename);
+
        return value;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]