TaskBar: Don't leak fds when reading battery info
This commit is contained in:
parent
391fc0c4c2
commit
f15f88ebd6
|
@ -27,6 +27,8 @@ static BAN::ErrorOr<long long> read_integer_from_file(const char* file)
|
|||
static BAN::String get_battery_percentage()
|
||||
{
|
||||
DIR* dirp = opendir("/dev/batteries");
|
||||
if (dirp == nullptr)
|
||||
return {};
|
||||
|
||||
BAN::String result;
|
||||
while (dirent* dirent = readdir(dirp))
|
||||
|
@ -53,6 +55,8 @@ static BAN::String get_battery_percentage()
|
|||
(void)result.append(string.value());
|
||||
}
|
||||
|
||||
closedir(dirp);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue