From 48156a7a2b1b0515fe2ef9f5d1201e158d5bd948 Mon Sep 17 00:00:00 2001 From: William Poetra Yoga <30787981+wpyh@users.noreply.github.com> Date: Fri, 7 Jun 2019 23:03:09 +0700 Subject: [PATCH] Prevent Segmentation Fault (#255) Fix a segmentation fault when no "-b" or "--backlight-preference" option is specified on the command line. --- plugins/power/csd-backlight-helper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/power/csd-backlight-helper.c b/plugins/power/csd-backlight-helper.c index 3b2e0a06..8d9c1d82 100644 --- a/plugins/power/csd-backlight-helper.c +++ b/plugins/power/csd-backlight-helper.c @@ -66,10 +66,12 @@ csd_backlight_helper_get_best_backlight (gchar** preference_list) goto out; /* setup our gsettings interface */ - if (preference_list[0] == NULL) + if (preference_list == NULL || preference_list[0] == NULL) { g_print("%s\n%s\n", "Warning: no backlight sources have been configured.", "Check " CSD_POWER_SETTINGS_SCHEMA " to configure some."); + goto out; + } int i = 0; for (i=0; preference_list[i] != NULL; i++) {