Bug 14947 - [PATCH] crash when starting up and battery charging
Summary: [PATCH] crash when starting up and battery charging
Status: RESOLVED FIXED
Alias: None
Product: hal
Classification: Unclassified
Component: hald (show other bugs)
Version: unspecified
Hardware: Other All
: high blocker
Assignee: David Zeuthen (not reading bugmail)
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-10 15:47 UTC by Diego
Modified: 2008-03-11 10:02 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Diego 2008-03-10 15:47:03 UTC
I saw a crash when hal was starting up and the laptop battery was charging. The crash was on line 195 of file util_pm.c.
It happends because saved_battery_info was NULL.

--- util_pm.c	2008-03-10 23:08:54.000000000 +0100
+++ util_pm.c~	2008-03-10 23:08:54.000000000 +0100
@@ -111,9 +111,6 @@
 {
 	int remaining_time = 0;
 
-	if (!saved_battery_info) 
-		saved_battery_info = g_hash_table_new(g_str_hash, g_str_equal);
-
 	/* should not get negative values */
 	if (chargeRate < 0 || chargeLevel < 0 || chargeLastFull < 0) {
 		HAL_WARNING (("chargeRate, chargeLevel or chargeLastFull < 0, returning -1"));
@@ -134,6 +131,8 @@
 		time_t cur_time = time(NULL);
 
 		/* Initialize the save_battery_info GHashTable */
+		if (!saved_battery_info) 
+			saved_battery_info = g_hash_table_new(g_str_hash, g_str_equal);
 
 		if ((battery_info = g_hash_table_lookup(saved_battery_info, id))) {
 			/* check this to prevent division by zero */
Comment 1 Danny Kukawka 2008-03-11 10:02:01 UTC
Thanks for the report, I fixed it in an other way to prevent not needed initialising of saved_battery_info.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.