Fix several (more) memory leaks.

A follow-up to r337812 to catch a couple more memory leaks that should
have been included in that change.

Reported by:	Coverity
CID:		1296064, 1296067 (for real this time)
MFC after:	3 days
X-MFC-with:	r337812
Sponsored by:	Dell EMC
This commit is contained in:
David Bright 2018-08-14 19:31:06 +00:00
parent b8abc9d8f5
commit 45bed28c11

View File

@ -235,10 +235,14 @@ kevent_add(int kqfd, struct kevent *kev,
intptr_t data,
void *udata)
{
char *kev_str;
EV_SET(kev, ident, filter, flags, fflags, data, NULL);
if (kevent(kqfd, kev, 1, NULL, 0, NULL) < 0) {
printf("Unable to add the following kevent:\n%s\n",
kevent_to_str(kev));
kev_str = kevent_to_str(kev);
printf("Unable to add the following kevent:\n%s\n",
kev_str);
free(kev_str);
err(1, "kevent(): %s", strerror(errno));
}
}
@ -246,6 +250,9 @@ kevent_add(int kqfd, struct kevent *kev,
void
kevent_cmp(struct kevent *k1, struct kevent *k2)
{
char *kev1_str;
char *kev2_str;
/* XXX-
Workaround for inconsistent implementation of kevent(2)
*/
@ -258,8 +265,12 @@ kevent_cmp(struct kevent *k1, struct kevent *k2)
k1->data != k2->data || k1->udata != k2->udata ||
k1->ext[0] != k2->ext[0] || k1->ext[1] != k2->ext[1] ||
k1->ext[0] != k2->ext[2] || k1->ext[0] != k2->ext[3]) {
kev1_str = kevent_to_str(k1);
kev2_str = kevent_to_str(k2);
printf("kevent_cmp: mismatch:\n %s !=\n %s\n",
kevent_to_str(k1), kevent_to_str(k2));
kev1_str, kev2_str);
free(kev1_str);
free(kev2_str);
abort();
}
}