From 5401e9117ce50ecfba3d86b0d4d84ef8fbdc396f Mon Sep 17 00:00:00 2001 From: Monsta Date: Sun, 16 Nov 2014 17:13:24 +0300 Subject: avoid dereferencing NULL pointer Closes https://github.com/mate-desktop/mate-applets/pull/114 --- battstat/acpi-linux.c | 12 +++++++++--- battstat/battstat-upower.c | 1 + battstat/power-management.c | 1 - 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'battstat') 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; } /* diff --git a/battstat/battstat-upower.c b/battstat/battstat-upower.c index 792be860..1326a9cc 100644 --- a/battstat/battstat-upower.c +++ b/battstat/battstat-upower.c @@ -320,6 +320,7 @@ error_dialog( const char *fmt , ...) va_start(ap, fmt); char str[1000]; vsprintf(str, fmt, ap); + va_end(ap); GtkWidget *dialog; dialog = gtk_message_dialog_new( NULL, 0, GTK_MESSAGE_ERROR, diff --git a/battstat/power-management.c b/battstat/power-management.c index c879bcaa..682f9683 100644 --- a/battstat/power-management.c +++ b/battstat/power-management.c @@ -443,7 +443,6 @@ const char * power_management_initialise (int no_hal, void (*callback) (void)) { char *err; - err = g_strdup( ":(" ); #ifdef __linux__ struct stat statbuf; #endif -- cgit v1.2.1