mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-01-08 15:00:23 +01:00
bugfix: don't crash when we limit the resolution of a small dataset
This commit is contained in:
parent
e3e060e4d2
commit
5b7dbc3f41
1 changed files with 8 additions and 1 deletions
|
|
@ -146,12 +146,18 @@ dkp_history_array_limit_resolution (EggObjList *array, guint max_num)
|
|||
guint step = 1;
|
||||
gfloat preset;
|
||||
|
||||
/* check length */
|
||||
length = array->len;
|
||||
if (length < max_num) {
|
||||
new = g_object_ref (array);
|
||||
goto out;
|
||||
}
|
||||
|
||||
new = dkp_history_new_stats_list ();
|
||||
nobj = dkp_history_obj_new ();
|
||||
egg_debug ("length of array (before) %i", array->len);
|
||||
|
||||
/* last element */
|
||||
length = array->len;
|
||||
obj = (const DkpHistoryObj *) egg_obj_list_index (array, length-1);
|
||||
last = obj->time;
|
||||
obj = (const DkpHistoryObj *) egg_obj_list_index (array, 0);
|
||||
|
|
@ -194,6 +200,7 @@ dkp_history_array_limit_resolution (EggObjList *array, guint max_num)
|
|||
/* check length */
|
||||
egg_debug ("length of array (after) %i", new->len);
|
||||
dkp_history_obj_free (nobj);
|
||||
out:
|
||||
return new;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue