Revert r300385 and r300624 which was false positive
reported by cppcheck. dup_ncp() tries to allocate a buffer of MAXNETCONFIGLINE as tmp, which is then assigned to p->nc_netid via strcpy, so the free(p->nc_netid) would have correctly released the memory in case nc_lookups() fails, therefore, the allerged leak never existed. MFC after: 3 days
This commit is contained in:
parent
86ce2be65a
commit
94c5b2d124
@ -692,7 +692,7 @@ static struct netconfig *
|
||||
dup_ncp(struct netconfig *ncp)
|
||||
{
|
||||
struct netconfig *p;
|
||||
char *tmp, *tmp2;
|
||||
char *tmp;
|
||||
u_int i;
|
||||
|
||||
if ((tmp=malloc(MAXNETCONFIGLINE)) == NULL)
|
||||
@ -701,7 +701,6 @@ dup_ncp(struct netconfig *ncp)
|
||||
free(tmp);
|
||||
return(NULL);
|
||||
}
|
||||
tmp2 = tmp;
|
||||
/*
|
||||
* First we dup all the data from matched netconfig buffer. Then we
|
||||
* adjust some of the member pointer to a pre-allocated buffer where
|
||||
@ -723,7 +722,6 @@ dup_ncp(struct netconfig *ncp)
|
||||
if (p->nc_lookups == NULL) {
|
||||
free(p->nc_netid);
|
||||
free(p);
|
||||
free(tmp2);
|
||||
return(NULL);
|
||||
}
|
||||
for (i=0; i < p->nc_nlookups; i++) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user