Remove memory leak: If the check of the data fails, the data itself is leaked.

Signed-off-by: Holger Vogt <holger.vogt@uni-due.de>
This commit is contained in:
Jim Monte 2019-03-30 09:57:37 +01:00 committed by Holger Vogt
parent 4afc5ed5b5
commit 6bce493d25
1 changed files with 9 additions and 3 deletions

View File

@ -50,11 +50,17 @@ ft_getpnames(wordlist *wl, bool check)
if (rv)
return (NULL);
if (check && !checkvalid(pn))
return (NULL);
/* If validation is requested, do it and return NULL on failure. The
* structure must also be freed if the check fails since it is not
* being returned. */
if (check && !checkvalid(pn)) {
free_pnode(pn);
return (struct pnode *) NULL;
}
return (pn);
}
} /* end of function ft_getpnames */
/* See if there are any variables around which have length 0 and are