Commit 659251c5 authored by Hisham Muhammad's avatar Hisham Muhammad
Browse files

Fix array limit.

parent e0209da8
...@@ -56,13 +56,14 @@ static unsigned long int parseBatInfo(const char *fileName, const unsigned short ...@@ -56,13 +56,14 @@ static unsigned long int parseBatInfo(const char *fileName, const unsigned short
if (!batteryDir) if (!batteryDir)
return 0; return 0;
char* batteries[64]; #define MAX_BATTERIES 64
char* batteries[MAX_BATTERIES];
unsigned int nBatteries = 0; unsigned int nBatteries = 0;
memset(batteries, sizeof batteries, sizeof (char*)); memset(batteries, MAX_BATTERIES, sizeof (char*));
struct dirent result; struct dirent result;
struct dirent* dirEntry; struct dirent* dirEntry;
while (nBatteries < sizeof batteries) { while (nBatteries < MAX_BATTERIES) {
readdir_r(batteryDir, &result, &dirEntry); readdir_r(batteryDir, &result, &dirEntry);
if (!dirEntry) if (!dirEntry)
break; break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment