When sysctlbyname fails, free buf before returning.

Submitted by:	Thomas Rix <trix@juniper.net>
Reviewed by:	jhb
Approved by:	sjg (mentor)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D9867
This commit is contained in:
stevek 2017-06-01 16:44:39 +00:00
parent bb1f43f35d
commit 038f656747

View File

@ -46,8 +46,10 @@ kinfo_getvmobject(int *cntp)
buf = NULL;
for (i = 0; i < 3; i++) {
if (sysctlbyname("vm.objects", NULL, &len, NULL, 0) < 0)
if (sysctlbyname("vm.objects", NULL, &len, NULL, 0) < 0) {
free(buf);
return (NULL);
}
buf = reallocf(buf, len);
if (buf == NULL)
return (NULL);