fixed some segfault and memleak

git-svn-id: http://tint2.googlecode.com/svn/trunk@195 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
lorthiois@bbsoft.fr
2009-09-25 19:11:50 +00:00
parent f81e1b2e90
commit 7b570efb8f
4 changed files with 26 additions and 11 deletions

View File

@@ -47,7 +47,7 @@ char *path_energy_now, *path_energy_full, *path_current_now, *path_status;
void init_battery()
{
// check battery
GDir *directory;
GDir *directory = 0;
GError *error = NULL;
const char *entryname;
char *battery_dir = 0;
@@ -69,7 +69,9 @@ void init_battery()
g_free(path1);
}
}
if (battery_dir != 0) {
if (directory)
g_dir_close(directory);
if (battery_dir) {
char *path1 = g_build_filename(battery_dir, "energy_now", NULL);
if (g_file_test (path1, G_FILE_TEST_EXISTS)) {
path_energy_now = g_build_filename(battery_dir, "energy_now", NULL);
@@ -161,6 +163,9 @@ void init_battery()
battery->bat1_posy -= ((bat_time_height_ink + 2) / 2);
battery->bat2_posy = battery->bat1_posy + bat_percentage_height + 2 - (bat_percentage_height - bat_percentage_height_ink)/2 - (bat_time_height - bat_time_height_ink)/2;
}
if (battery_dir)
g_free(battery_dir);
}