[PATCH 04/10] daemon: plug huge memleak in GetStatistics

Peter Wu peter at lekensteyn.nl
Wed Nov 26 03:21:11 PST 2014


Reproducible by executing `upower -d` or by calling the DBus method
org.freedesktop.UPower.Device.GetStatistics(charging).
up_device_get_statistics ->
  up_history_get_profile_data ->
    up_stats_item_new.

https://bugs.freedesktop.org/show_bug.cgi?id=82659
---
 src/up-history.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/up-history.c b/src/up-history.c
index 4ed55fc..1d41c2c 100644
--- a/src/up-history.c
+++ b/src/up-history.c
@@ -299,7 +299,7 @@ up_history_get_profile_data (UpHistory *history, gboolean charging)
 	g_return_val_if_fail (UP_IS_HISTORY (history), NULL);
 
 	/* create 100 item list and set to zero */
-	data = g_ptr_array_new ();
+	data = g_ptr_array_new_full (101, g_object_unref);
 	for (i=0; i<101; i++) {
 		stats = up_stats_item_new ();
 		g_ptr_array_add (data, stats);
-- 
2.1.3



More information about the devkit-devel mailing list