Fix array limit.

This commit is contained in:
Hisham Muhammad 2014-04-24 19:43:27 -03:00
parent e0209da88f
commit 659251c501
1 changed files with 4 additions and 3 deletions

View File

@ -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;