Fix crash when D-Bus isn't available

This commit is contained in:
Bastien Nocera 2013-11-08 16:32:08 +01:00
parent 78993a76cd
commit 4c187d769f
2 changed files with 36 additions and 1 deletions

View File

@ -0,0 +1,29 @@
From 0d64bbddaa0078ef148d609a3cfad854cf00d7de Mon Sep 17 00:00:00 2001
From: Martin Pitt <martinpitt@gnome.org>
Date: Fri, 8 Nov 2013 14:59:50 +0100
Subject: [PATCH] lib: Fix segfault on getting property when daemon is not
running
This fixes "upower --version" when the daemon is not running, and thus the
client proxy is NULL.
---
libupower-glib/up-client.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libupower-glib/up-client.c b/libupower-glib/up-client.c
index 35d7b5d..17fb02d 100644
--- a/libupower-glib/up-client.c
+++ b/libupower-glib/up-client.c
@@ -322,6 +322,9 @@ up_client_get_property (GObject *object,
UpClient *client;
client = UP_CLIENT (object);
+ if (client->priv->proxy == NULL)
+ return;
+
switch (prop_id) {
case PROP_DAEMON_VERSION:
g_value_set_string (value, up_client_glue_get_daemon_version (client->priv->proxy));
--
1.8.4.2

View File

@ -1,7 +1,7 @@
Summary: Power Management Service
Name: upower
Version: 0.99.0
Release: 1%{?dist}
Release: 2%{?dist}
License: GPLv2+
Group: System Environment/Libraries
URL: http://upower.freedesktop.org/
@ -25,6 +25,8 @@ Requires: polkit >= 0.92
Requires: udev
Requires: gobject-introspection
Patch0: 0001-lib-Fix-segfault-on-getting-property-when-daemon-is-.patch
%description
UPower (formerly DeviceKit-power) provides a daemon, API and command
line tools for managing power devices attached to the system.
@ -40,6 +42,7 @@ Headers and libraries for UPower.
%prep
%setup -q
%patch0 -p1
%build
%configure \
@ -97,6 +100,9 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
%{_includedir}/libupower-glib/upower.h
%changelog
* Fri Nov 08 2013 Bastien Nocera <bnocera@redhat.com> 0.99.0-2
- Fix crash when D-Bus isn't available
* Tue Oct 29 2013 Richard Hughes <rhughes@redhat.com> - 0.99.0-1
- New upstream release
- This version contains major API changes and bumps library soname.