Fix the resource leak of a 'FILE *' which could happen in routine

ctl_readcf() if a call to malloc failed.

PR:		204955
Reported by:	David Binderman
This commit is contained in:
Garance A Drosehn 2018-03-12 01:41:16 +00:00
parent df5f14797b
commit 02e8b7b2e7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=330787

View file

@ -292,8 +292,10 @@ ctl_readcf(const char *ptrname, const char *cfname)
msize = sroom2 + CTI_LINEMAX;
msize = roundup(msize, 8);
cstart = malloc(msize);
if (cstart == NULL)
if (cstart == NULL) {
fclose(cfile);
return NULL;
}
memset(cstart, 0, msize);
cpriv = (struct cjprivate *)cstart;
cpriv->pub.cji_priv = cpriv;