powerd(8): Fix a memory leak when we fail to read frequency levels.

PR:		242967
Submitted by:	Hans Christian Woithe <chwoithe@yahoo.com>
MFC after:	3 days
This commit is contained in:
markj 2019-12-29 20:57:49 +00:00
parent 3bf92db198
commit 2774665e4b

View File

@ -196,8 +196,10 @@ read_freqs(int *numfreqs, int **freqs, int **power, int minfreq, int maxfreq)
return (-1); return (-1);
if ((freqstr = malloc(len)) == NULL) if ((freqstr = malloc(len)) == NULL)
return (-1); return (-1);
if (sysctl(levels_mib, 4, freqstr, &len, NULL, 0)) if (sysctl(levels_mib, 4, freqstr, &len, NULL, 0)) {
free(freqstr);
return (-1); return (-1);
}
*numfreqs = 1; *numfreqs = 1;
for (p = freqstr; *p != '\0'; p++) for (p = freqstr; *p != '\0'; p++)