inetd: don't leak policy on return

sep->se_policy gets a strdup'd version of policy, so we don't need it to
stick around afterwards.

While here, remove a couple of NULL checks prior to free(policy).

CID:		1006865
MFC after:	3 days
This commit is contained in:
kevans 2019-12-30 15:54:36 +00:00
parent 86dbfb2210
commit a5969606ca

View File

@ -1629,12 +1629,10 @@ getconfigent(void)
for (p = cp + 2; p && *p && isspace(*p); p++)
;
if (*p == '\0') {
if (policy)
free(policy);
free(policy);
policy = NULL;
} else if (ipsec_get_policylen(p) >= 0) {
if (policy)
free(policy);
free(policy);
policy = newstr(p);
} else {
syslog(LOG_ERR,
@ -1969,6 +1967,7 @@ getconfigent(void)
LIST_INIT(&sep->se_conn[i]);
#ifdef IPSEC
sep->se_policy = policy ? newstr(policy) : NULL;
free(policy);
#endif
return (sep);
}