summaryrefslogtreecommitdiff
path: root/battstat/acpi-linux.c
diff options
context:
space:
mode:
authorMonsta <[email protected]>2014-11-16 17:13:24 +0300
committerStefano Karapetsas <[email protected]>2014-11-26 09:54:20 +0100
commit5401e9117ce50ecfba3d86b0d4d84ef8fbdc396f (patch)
tree9002f0a320290a516767e181059ee8be18818ca8 /battstat/acpi-linux.c
parentc5e3a3c796cb9397871e6f4da5d9afa454e311a6 (diff)
downloadmate-applets-5401e9117ce50ecfba3d86b0d4d84ef8fbdc396f.tar.bz2
mate-applets-5401e9117ce50ecfba3d86b0d4d84ef8fbdc396f.tar.xz
avoid dereferencing NULL pointer
Closes https://github.com/mate-desktop/mate-applets/pull/114
Diffstat (limited to 'battstat/acpi-linux.c')
-rw-r--r--battstat/acpi-linux.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/battstat/acpi-linux.c b/battstat/acpi-linux.c
index 3ac91c29..6f9512ce 100644
--- a/battstat/acpi-linux.c
+++ b/battstat/acpi-linux.c
@@ -350,22 +350,28 @@ gboolean acpi_process_event(struct acpi_info * acpiinfo)
buffer=g_string_new(NULL);
g_io_channel_read_line_string ( acpiinfo->channel,buffer,&i,&gerror);
+ gboolean result;
evt = parse_acpi_event(buffer);
switch (evt) {
case ACPI_EVENT_AC:
- return update_ac_info(acpiinfo);
+ result = update_ac_info(acpiinfo);
+ break;
case ACPI_EVENT_BATTERY_INFO:
if (update_battery_info(acpiinfo)) {
/* Update AC info on battery info updates. This works around
* a bug in ACPI (as per bug #163013).
*/
- return update_ac_info(acpiinfo);
+ result = update_ac_info(acpiinfo);
+ break;
}
/* fall-through */
default:
- return FALSE;
+ result = FALSE;
}
+
+ g_string_free(buffer, FALSE);
+ return result;
}
/*