mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-05-05 06:28:00 +02:00
don't crash if we do GetStatistics on a device without history
This commit is contained in:
parent
0e617b862c
commit
fad9b70a7a
1 changed files with 7 additions and 0 deletions
|
|
@ -904,6 +904,13 @@ dkp_source_get_statistics (DkpSource *source, const gchar *type, guint timespan,
|
|||
goto out;
|
||||
}
|
||||
|
||||
/* maybe the device doesn't support histories */
|
||||
if (array == NULL) {
|
||||
error = g_error_new (DKP_DAEMON_ERROR, DKP_DAEMON_ERROR_GENERAL, "device has no history");
|
||||
dbus_g_method_return_error (context, error);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* copy data to dbus struct */
|
||||
complex = g_ptr_array_sized_new (array->len);
|
||||
for (i=0; i<array->len; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue