Before returning because of an memory allocation error, free the memory

already allocated to buf.

Found using clang's static analyzer - scan-build

Submitted by:	Thomas Rix <trix@juniper.net>
Reviewed by:	stevek
Approved by:	sjg (mentor)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D9852
This commit is contained in:
Stephen J. Kiernan 2017-06-06 21:51:04 +00:00
parent 7c91b65f54
commit ba01ab64cc

View File

@ -145,6 +145,7 @@ iface_Create(const char *name)
iface = (struct iface *)malloc(sizeof *iface);
if (iface == NULL) {
fprintf(stderr, "iface_Create: malloc: %s\n", strerror(errno));
free(buf);
return NULL;
}
iface->name = strdup(name);