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:
Mark Johnston 2019-12-29 20:57:49 +00:00
parent 758b2c02bb
commit 2a73387f1c

View File

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